Bug Tracker

Modify

Ticket #8441 (closed bug: worksforme)

Opened 2 years ago

Last modified 2 years ago

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

comment:1 Changed 2 years ago by jaubourg

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.

comment:2 Changed 2 years ago by jaubourg

  • Component changed from unfiled to ajax

comment:3 Changed 2 years ago by jaubourg

  • Status changed from new to closed
  • Resolution set to worksforme

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.