title: Parse PHP array of objects with jQuery Ajax
body: <p>I'm trying to get an array of objects with data from my database into jquery to render on a website. </p>
  
  <p>ex:
  example.php</p>
  
  <pre><code>&lt;?php
  function testFunction() {
  
  $data = array()
  $mydata = new stdClass;
  $mydata-&gt;example = 'test';
  $data[] = $mydata
  return json_encode($data);
  }
  
  echo testFunction();
  ?&gt;
  </code></pre>
  
  <p>ex
  index.html</p>
  
  <pre><code>&lt;script&gt;
  $.ajax({
                      type: 'POST',
                      url: 'example.php',
                      data: {map: map},   
                      cache: false,
                      dataType: 'json',                 
                      success: function(response) {
                        console.log(response[0].example);
                      }
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Output:</p>
  
  <p>console.log(response);</p>
  
  <p>["test", $family: function, $constructor: function, each: function, clone: function, clean: function…]</p>
  
  <p>console.log(response[0].example);</p>
  
  <p>undefined </p>
  
  <p>So essentially, I receive the response fine, when I log it it gives me a structure that makes sense. however I can't seem to find the correct way of accessing my objects inside the array, the example I have above only returns undefined. What is the correct syntax for this please?</p>