title: Ajax status code 0 on page reload
body: <p>I have an application, which retrieves some page data via $.ajax call on <strong>page load</strong> (no other bindings, like 'click' etc.). In a scenario, when user reloads page (or navigates to another page) before the response arrives, the application returns an error (error event <a href="http://api.jquery.com/ajaxError/" rel="nofollow">ajaxError()</a> is triggered) with status code 0.</p>
  
  <p>When I was doing my homework and read around SO (and lots of other places) I came across the posts where people simply ignored errors of this kind by doing the following:</p>
  
  <pre><code>$(document).ajaxError(function(e, jqxhr, settings, exception) {  
    if (jqxhr.readyState == 0 || jqxhr.status == 0) {  
      return; //Skip this error  
    }  
  });  
  </code></pre>
  
  <p>Is it safe to presume that only this kind of errors will be ignored? Can any negative scenarios appear that would need 'special attention'?</p>
  
  <p>ALSO:</p>
  
  <p>I've found some replies to similar issues stating that putting 'return false;' or 'preventDefault' solved their issue. But in my case everything is happening on page load, so I can't 'hook' on any of mentioned events... Or can I?</p>
  
  <p><strong>EDIT:</strong> The additional question here is: is there any other way of handling these situations (ajax request being interrupted by page reload)? The thing is that I have error reporting bound on the general ajaxError event and I'd like to filter out messages like this (or maybe even prevent them from happening in the first place)? </p>