title: Get data from PHP array via AJAX and jQuery
body: <p>I have a page as below:</p>
  <pre><code>&lt;head&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.6.1.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready( function() {
  $('#prev').click(function() {
    $.ajax({
    type: 'POST',
    url: 'ajax.php',
    data: 'id=testdata',
    cache: false,
    success: function(result) {
      $('#content1').html(result[0]);
    },
    });
  });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td id=&quot;prev&quot;&gt;prev&lt;/td&gt;
  &lt;td id=&quot;content1&quot;&gt;X&lt;/td&gt;
  &lt;td id=&quot;next&quot;&gt;next&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>
  <p>and a php file <code>ajax.php</code> to handle ajax requests as;</p>
  <pre><code>&lt;?php
  $array = array(1,2,3,4,5,6);
  echo $array;
  ?&gt;
  </code></pre>
  <p>But when I click, I am getting <code>A</code> instead of array[0]. How can I fix this?</p>