If you take a look at $.ajax implementation you will find these lines of code:
// Callback for when everything is done
function done(status, nativeStatusText, responses, headers) {
...
// Determine if successful
isSuccess = status >= 200 && status < 300 || status === 304;
...
// Success/Error
if (isSuccess) {
deferred.resolveWith(callbackContext, [success, statusText, jqXHR]);
} else {
deferred.rejectWith(callbackContext, [jqXHR, statusText, error]);
}
...
}
So the answer is that codes in range 200-300 and 304 are considered successful, and everything else is a failure. Based on that they resolve (done
, success
methods will be called) or reject (fail
) deferred object.