title: Return PHP array after AJAX call
body: <p>I'm sending an JS object via $.post() and I want to get an array back.</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var ajaxData = {action:"createuser"}
  $("input[required]").each(function(){
      var attr = $(this).attr("name");
      ajaxData[attr] = $(this).val();
  });
  $.post(
      daten.ajaxurl,
      ajaxData, 
      function(data){
         alert(data[0])
      }        
   )
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>//Create a User
  add_action('wp_ajax_nopriv_createuser','createuser');
  function createuser () {
      foreach ($_POST as $key =&gt; $value) {
          if(empty($value)) {
              $type = "error";
              $content = "$key is empty";
              echo array($type,$content);
              wp_die();
          }
      }
  }
  </code></pre>
  
  <p>What I get as a response is always a string, so it works well if I echo $content.</p>
  
  <p>I've read about that you can use JSON and get it automatically encode if you add DataTaype: "JSON".</p>
  
  <p>But I have no idea how to properly decode it in PHP, tho</p>