title: Fail callback called although Ajax request is performed and server returns 200 with data
body: <p>I have a HTML5 test webpage <code>test.html</code> with a cache manifest. The webpage does an Ajax request to the same server, to a webpage <code>do_get_data.php</code> that is listed under the section <code>NETWORK:</code> in the cache manifest.</p>
  
  <p>The request is performed by both Firefox 10 and iPhone iOS 5 Safari (this is logged in the serving PHP script <code>do_get_data.php</code>). Firefox 10 calls the <code>success</code> callback function after 10 seconds, that is, when data from the server is returned. However, my iPhone iOS 5 Safari calls the <code>fail</code> callback function immediately after it started the request and doesn't call the <code>success</code> callback function.</p>
  
  <p>For iPhone iOS 5 Safari, the <code>textStatus</code> is <code>error</code> and <code>JSON.stringify(jqXHR)</code> is <code>{"readyState":0,"responseText":"","status":0,"statusText":"error"}</code>.</p>
  
  <p>The request is performed using the following code in <code>test.html</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt;
      function test_ok(data) {
          alert('Test OK, data: ' + JSON.stringify(data));
      }
      function testFail(jqXHR, textStatus) {
          alert(textStatus + ' | ' + JSON.stringify(jqXHR));
      }
      function get_data(testurl) {
          var senddata, request;
          alert('Request for ' + testurl + ' started.');
          window.testid = new Date().getTime();
          senddata = {
              background: true,
              requestId: window.testid
          };
          request = $.ajax({
              url: testurl,
              cache: false,
              type: "GET",
              data: senddata,
              success: test_ok
          });
          request.fail(testFail);
      }
  &lt;/script&gt;
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="button" onclick="get_data('do_get_data.php')" value="test sending" /&gt;
  </code></pre>
  
  <p>For reference, <code>do_get_data.php</code> looks like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      $id = md5(rand() . rand());
      trigger_error(implode("\t", array('start', $id, $_SERVER['REQUEST_URI'], $_SERVER['REMOTE_ADDR'], $_SERVER['USER_AGENT']));
      sleep(10);
      header('Content-Type: application/json');
      $json = json_encode(array('msg'=&gt;'Test was OK'));
      trigger_error(implode("\t", array('echo', $id, $json));
      echo $json;
  ?&gt;
  </code></pre>