title: Php stdclass object returned to ajax
body: <p>I have only recently started usign ajax and i have run into a slight problem.
  The code is as follows: </p>
  
  <ol>
  <li>Input form -> Value to AJAX.</li>
  <li>AJAX sends the form value to a php function that sends the request to a server.</li>
  <li>The server returns a stdClass object with the query results.</li>
  <li>PHP sends the results as responseText back to AJAX to be displayed on the webapp.</li>
  </ol>
  
  <p><strong>The problem:</strong></p>
  
  <p>stdClass Object is a PHP object that i now am stuck with, it is not possible to change the output format of the server in question. </p>
  
  <p>I have tried all the possible array/object/variable - combinations i can think of and also tried to json_encode the object. However this solutions only returns a long set of strings, as does a var_dump on the object. I might be horrible wrong, having absolutely no experience with json.</p>
  
  <p>I need some guidance on how to pass the object to AJAX in a format i can output with JavaScript.</p>
  
  <p><strong>AJAX Code:</strong> </p>
  
  <pre><code>function checkSerial(serial) {
  
          console.log(serial);
  
        if (window.XMLHttpRequest) {
          // code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
        } else {  // code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
  
        xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
            $responseText=xmlhttp.responseText;
            console.log($responseText);
          }
        }
  
        xmlhttp.open("GET","../module/getdevice.php?serial="+serial, true);
        xmlhttp.send();
  
  }
  </code></pre>
  
  <p><strong>Outputted stdClass. Sorry about the censored values.</strong></p>
  
  <pre><code>object(stdClass)#5 (15) {
    ["censored"]=&gt;
    string(12) "censored"
    ["censored"]=&gt;
    string(29) "censored"
    ["censored"]=&gt;
    string(1) "censored"
    ["censored"]=&gt;
    string(8) "censored"
    ["censored"]=&gt;
    string(7) "censored"
    ["censored"]=&gt;
    string(0) "censored"
    ["censored"]=&gt;
    string(56) "censored"
    ["censored"]=&gt;
    string(47) "censored"
    ["censored"]=&gt;
    string(47) "censored"
    ["censored"]=&gt;
    string(30) "censored"
    ["censored"]=&gt;
    string(14) "censored"
    ["censored"]=&gt;
    string(0) "censored"
    ["censored"]=&gt;
    string(0) "censored"
    ["censored"]=&gt;
    string(0) "censored"
    ["censored"]=&gt;
  </code></pre>
  
  <p>Hopefully this post is not a duplicate, i have tried my best to actively search for a solution.
  Thank you in advance !</p>