title: jQuery AJAX response object logs keys on console as undefined
body: <p><strong>Accepted answer by Rohan Kumar:</strong></p>
  
  <p>Changed $.post() into</p>
  
  <pre><code>$.post("monitor/loadEVents", function(data){
      if(data &amp;&amp; data.response){                    // (didn't even have to change this for it to work, but I like this condition more than my own one)
          console.log('Wow, it works.');
      } else {
          console.log(data);
      }
  },'json');                 // put the third parameter as json
  </code></pre>
  
  <p><strong>Original question below:</strong></p>
  
  <p>I'm trying jQuery AJAX for the first time in Zend Framework 2 (I've never worked with AJAX before at all). That being said, I don't have very extensive experience in working with JSON yet either, so please forgive me for rookie mistakes ;) </p>
  
  <p>In my js file I'm calling a function in my controller to return a JSON object. My problem is that when I log 'data' to the console, it logs the structure of it just fine, but when I try to do something with the keys of 'data', their values come back as undefined. </p>
  
  <p>This is where I call the function:</p>
  
  <pre><code>$('#loadmore').on('click', function(event){
      $.post("monitor/loadEVents", function(data){
          if(data.response == true){
              console.log('Wow, it works.');       // Want this condition met, but it never is.
          } else {
              console.log(data);                   // so it logs data
          }
      })
  });
  </code></pre>
  
  <p>Here's the function inside my controller:</p>
  
  <pre><code>public function loadEventsAction(){
      $request    = $this-&gt;getRequest();
      $response   = $this-&gt;getResponse();
      if($request-&gt;isPost()){
          $events = array('a bunch' =&gt; 'of stuff');
          $response-&gt;setContent(\Zend\Json\Json::encode(array('response' =&gt; true, 'events' =&gt; $events)));
      }
      return $response;
  }
  </code></pre>
  
  <p>This is how it logs data:</p>
  
  <pre><code>{"response":true,"events":{"a bunch":"of stuff"}} 
  </code></pre>
  
  <p>What do I do so I can get to the response and events keys in 'data' properly?</p>