yura
yura

Reputation: 14655

What is ajax error?

What server response cause ajaxError on browser Ajax handler? Is this error code different from 200 or not empty special json field?

Upvotes: 1

Views: 1925

Answers (1)

Nick Craver
Nick Craver

Reputation: 630569

Yes, non-200 response codes can cause an error, you can see what constitutes "success" here:

httpSuccess: function( xhr ) {
    try {
        // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
        return !xhr.status && location.protocol === "file:" ||
            xhr.status >= 200 && xhr.status < 300 ||
            xhr.status === 304 || xhr.status === 1223;
    } catch(e) {}

    return false;
}

This is as of jQuery 1.4.4, previous a status code of 0 was also successful, because Opera 304 was reported as a 0...that leniency has since been removed to eliminate false positives for success. If the above check is false, the error handler is called.

Upvotes: 1

Related Questions