title: AJAX: How can I return an object to jquery?
body: <p>I'm wondering if I can return an object from <code>json_encode()</code> to JQuery.  If I were to do something like this...</p>
  
  <pre><code>$.ajax({
     type : 'POST',
     url  : 'next.php',
     dataType : 'json',
     data     : { nextID : 2 },
     success  : function ( data ) {
  
              // do something with data.myObject.memberVariable
  
            },
        error    : function ( XMLHttpRequest, textStatus, errorThrown) {
  
             //  didn't work!
  
        }
  });     
  </code></pre>
  
  <p>AND this (next.php)</p>
  
  <pre><code>&lt;?php
  
  include_once('myClass.php');
  
  $myObj = getMyObject( $_POST['nextID'] );  // get an object
  
  $return['myObject'] = $myObj;
  
  echo json_encode($return);
  
  ?&gt;
  </code></pre>
  
  <p>Now I've tested this method but whenever i try to do <code>data.myObject.memberVariable</code> all i get is <code>[object Object]</code>.  How can I actually access the variables of the object?  Hopefully the code above helps explain my question :(</p>