title: Empty XmlHttpRequest.response but XHR contains my data
body: <p>I'm new to JS and i'm using XHR in order to connect a mongodb hosted on mongolab.</p>
  
  <p>I use REST because mongo don't have a js driver (they got only node.js driver and I can't use it for my project).
  So, I use a GET request on my DB, then I don't know how to retrieve the response.
  Here is my GET function :</p>
  
  <pre><code>function getRequest(callback){
    var xhr = getXMLHttpRequest();
    xhr.onreadystatechange = function() {
          if (xhr.readyState == 4 &amp;&amp; (xhr.status == 200 || xhr.status == 0)) {
             callback(xhr.responseText);
          }
      };
  
    xhr.open("GET",restURI+apiKey, true);
    xhr.send(null);
    console.log(xhr);
    console.log(xhr.responseText); 
  }
  function readData(sData) {
     XHR reading
      if (sData == "OK") {
          alert("All clear");
      } else {
          alert("Some issues");
      }
  }
  </code></pre>
  
  <p>I got an empty string when I try :</p>
  
  <pre><code>console.log(xhr.response);
  </code></pre>
  
  <p>So I use to suppose that I failed in my REST request but no, when logging the xhr object i got this : </p>
  
  <p><img src="https://i.stack.imgur.com/7ee2R.png" alt="Server response"></p>
  
  <p>So my questions are : </p>
  
  <ol>
  <li>Why <code>response</code> and <code>responseText</code> are empty on the first line of the xhr object ?</li>
  <li>How do I retrieve my data ?</li>
  </ol>