Modify ↓
Ticket #8441 (closed bug: worksforme)
jQuery.ajax should call the error handler on 4xx responses
| Reported by: | lucas@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | ajax | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When a requests returns a 4xx as status code, the specified "error" handler should be called, because 4xx status codes indicate an error: "The 4xx class of status code is intended for cases in which the client seems to have erred" from RFC 2616[1]
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
$.ajax({
url: some/url.html, // This page should return, for example, a 403 Permission denied
error: function() {
console.log('Error');
},
complete: function(jqXHR, textStatus) {
if(parseInt(jqXHR.status) === 403) {
console.log('Permission denied');
}
}
});
Expected console output:
Permission denied. Error.
Actual output:
Permission denied.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Could you provide a proper, minimal, test case using jsFiddle or even a static page on a server you own? Also, what browser do you see this behaviour on? Do you use one or several plugins?
Also, on a sidenote, the expected behaviour would be:
in that order.