title: xmlhttp request status always returns 0
body: <p>I have a function which does get requests using plain old JS.</p>
  
  <pre><code>function get(url,funct){
      var xmlhttpget = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
      xmlhttpget.onreadystatechange=function(){
          if (xmlhttpget.readyState==4 &amp;&amp; xmlhttpget.status==200){
              funct(xmlhttpget.responseText);
          }
      }
      xmlhttpget.open("GET",url,true);
      xmlhttpget.send();
  }
  </code></pre>
  
  <p>I use it like this:</p>
  
  <blockquote>
    <p>get(url, function(resp){ window.alert(resp); });</p>
  </blockquote>
  
  <p>When my callback function stopped working I modified my <code>get()</code> function to the following for debugging:</p>
  
  <pre><code>function get(url,funct){
      var xmlhttpget = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
      xmlhttpget.onreadystatechange=function(){
          window.alert("ready state: "+xmlhttpget.readyState+" // status: "+xmlhttpget.status);
          if (xmlhttpget.readyState==4 &amp;&amp; xmlhttpget.status==200){
              window.alert("responded...");
              funct(xmlhttpget.responseText);
          }
      }
      window.alert(url);
      xmlhttpget.open("GET",url,true);
      xmlhttpget.send();
  }
  </code></pre>
  
  <p>With this I discovered that, during each readystate change the readystate will progress from 1 to 2 to 4, but the status always stays at 0 so my callback is never called, however, when I copy the alerted url to the browser it works fine.</p>
  
  <p>What's going on? Is my browser caching the page? How can I fix it (set a specific header on the requested page with php??)?</p>
  
  <p>Oh, not sure if this is relevant, but the page that's calling the function is inside of a frame whose parent document includes the same JavaScript file.</p>