PHP returning status 0
<p>I am having a problem with AJAX, where the PHP returns a status code of 0. I am running it on a local domain, and I don't see why it wont return anything. It does write to bar.txt, but it does not return anything to the AJAX request, and the status code is 0.</p>

<p>Ajax request:</p>

<pre><code>function sendRequestToButler(requestText, callback) {
  try {
    var request = new XMLHttpRequest();
    request.onreadystatechange = function() {if(request.readyState == 4 &amp;&amp; request.status == 200) {callback(request);} else {alert("Error: AJAX: readyState: " + request.readyState + " status: " + request.status);}};
    request.open("POST", "foo.php", true);
    request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    request.setRequestHeader("Content-length", requestText.length);
    request.setRequestHeader("Connection", "close");
    request.send(request);
  } catch(e) {alert("error"); return "CouldNotCompleteRequest";}
}
</code></pre>

<p>foo.php:</p>

<pre><code>&lt;?php
  file_put_contents('bar.txt', "facepalm", LOCK_EX);
  echo "foobar";
?&gt;
</code></pre>
