title: AJAX - Failed to load resource: net::ERR_EMPTY_RESPONSE
body: <p>I'm running some javascript which uses a setInterval to trigger an AJAX request and then performs some actions based on the returned output. I'm quite confused with it, because it works perfectly on my home server, but now that I've put it out onto the web, I'm having problems.</p>
  
  <p>The following error appears on Google Chrome:</p>
  
  <pre><code>http://www.domain.com/ajax/sound.php 
  Failed to load resource: net::ERR_EMPTY_RESPONSE
  </code></pre>
  
  <p>The error doesn't occur consistently however. Sometimes the scripts run for several minutes before an error occurs. Sometimes it all breaks down in seconds.</p>
  
  <p>I've already checked the obvious solution - that my server-side script is returning nothing. I did this by commenting out the entire script and having it do nothing but return information. That didn't help.</p>
  
  <p>I have several AJAX requests running from the same page, and all of them eventually return the same error (with their respective pages of code). I've tried isolating the requests and performing them one at a time at a slowed down rate, and have determined that the requests work in a general sense, but as soon as one of them sends an error, they all completely stop working and start sending the same error.</p>
  
  <p>Once the errors occur, I get no response when I try to access any part of my site (even parts with no AJAX). Safari says "...the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. Wait for a few minutes, and then try again." I've tried this in Explorer, Chrome, and Firefox as well with similar results. Thankfully, the site does come back up after a few minutes of making no AJAX requests.</p>
  
  <p>An example of one of the AJAX requests is as follows:</p>
  
  <pre><code>//At the set interval, we create a string for the request:
  
  function alef(){
      string = "a='a'";
      request(sound, "ajax/sound.php", string);
  }
  
  //That function fires off an AJAX request:
  
  function request(fix, url, string){
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
          if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
              fix(xhttp.responseText);
          }
      }
      xhttp.open("POST", url, true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhttp.send(string);
  }
  
  //The AJAX request returns a result to be processed by the following function:
  
  function sound(text){
      if(text == "sound"){
          insound.play();
      }
  }
  </code></pre>
  
  <p>Presume that my sound.php files says:</p>
  
  <pre><code>&lt;?php echo "sound"; ?&gt;
  </code></pre>
  
  <p>It doesn't say only that, but even when it did for testing purposes, I had the same problem.</p>
  
  <p>Any solutions?</p>