Skip to main content

Bug Tracker

Side navigation

#8441 closed bug (worksforme)

Opened March 04, 2011 03:06PM UTC

Closed March 11, 2011 06:11PM UTC

jQuery.ajax should call the error handler on 4xx responses

Reported by: lucas@x3ro.de Owned by:
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:
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.
Attachments (0)
Change History (3)

Changed March 04, 2011 06:20PM UTC by jaubourg comment:1

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:

Error
Permission denied

in that order.

Changed March 09, 2011 12:41AM UTC by jaubourg comment:2

component: unfiledajax

Changed March 11, 2011 06:11PM UTC by jaubourg comment:3

resolution: → worksforme
status: newclosed