title: How does jQuery's .ajax method define a 'failed' request?
body: <p>Surprisingly, the <a href="http://api.jquery.com/jquery.ajax/" rel="nofollow noreferrer">documentation for <code>.ajax</code></a> does not appear to define the terms 'success' and 'fail' anywhere.</p>
  
  <p>There are the obvious rules, for example:</p>
  
  <ul>
  <li>Any <code>4xx</code> or <code>5xx</code> status code will trigger <code>.fail()</code></li>
  <li>Any <code>2xx</code> status code will trigger <code>.done()</code> (success)</li>
  </ul>
  
  <p>However there appears to be some additional logic, beyond the response codes, that <code>.ajax</code> uses to decide whether a response "failed".  </p>
  
  <p>For example, it would appear that if the response cannot be parsed according to the chosen <code>dataType</code>, this counts as a failure.  This is especially the case, for example, if <code>dataType: json</code> is set:</p>
  
  <blockquote>
    <p>The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead.</p>
  </blockquote>
  
  <p>What is the complete list of rules that jQuery uses to determine whether a request succeeded or not?</p>