title: How to return an array from an AJAX call?
body: <p>I'm searching for a better solution to making an AJAX call with jQuery, having the PHP file return an array, and have it come out client-side as a Javascript array. Here is what I have been doing this:</p>
  
  <p>PHP File (Example.php):  </p>
  
  <pre><code>&lt;?php
      $id_numbers = array('NES-ZL','NES-AL','SNS-ZL');
  
      for ($i=0; $i&lt;count($the_array); $i++){
          echo $id_numbers[$i];
          echo '|';
      }
  ?&gt;
  </code></pre>
  
  <p>JS File:  </p>
  
  <pre><code>id_numbers = new Array();
  $.ajax({
      url:"Example.php",
      type:"POST",
      success:function(msg){
          id_numbers = msg.split('|');
      }
  });
  </code></pre>
  
  <p>My current method is just a little too convoluted for my taste.</p>
  
  <p>What I'd like to do is to be able to just</p>
  
  <pre><code>return $id_numbers;
  </code></pre>
  
  <p>on the PHP side and directly translate it to a Javascript array after the AJAX call.</p>
  
  <p>Ideas, anyone?</p>