Bug Tracker

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#2994 closed bug (fixed)

$.ajax error on 404 in IE

Reported by: Jeff Owned by:
Priority: high Milestone: 1.5
Component: ajax Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

Hi all, I have a problem on ajax error event handler with non existing file on url parameter -> 404 feedback ( the other event success / complete works fine all browser ). With the code below, FF 2.0.0.14 and OPERA 9.27 fire error event but IE 7 and SAFARI 3.1.1 not.

Thanks in advance, i start to look in your code ...

$.ajax (
	 {
	 type: 'POST',
	 url: 'a file that do not exist',
  	 dataType: 'HTML',
         data :'test=1',
	 success: function (data, textStatus) {	
             alert('success');
             },
         error: function (XMLHttpRequest, textStatus, errorThrown) {	 
	     alert('error');
             },
         complete : function(XMLHttpRequest, textStatus) {
	     alert('complete');
             }
         } 
      );

Change History (11)

comment:1 in reply to:  description Changed 11 years ago by Jeff

Adding "
xhr.status == 404" fix the problem, don't forget to add it in future release ;-)

comment:2 Changed 11 years ago by Jeff

Oups sorry guys that still don't work ( forget to update some cache ), if i check the header on requested file that don't exist by using http://web-sniffer.net i have a nice and normal 302. If i display the xhr.status but adding alert('xhr status = '+xhr.status); inside Jquery a have this result :

FF xhr.status = 302 OPERA xhr.status = 0 IE xhr.status = 200 SAFARI = no display at all

.....

comment:3 Changed 11 years ago by Jeff

Method GET correct IE pb - Still don't work on Safari

comment:4 Changed 11 years ago by flesler

Component: coreajax

comment:5 Changed 11 years ago by dmethvin

Is it possible that cache: true (the default) is part of the reason?

comment:6 Changed 9 years ago by dmethvin

Resolution: worksforme
Status: newclosed

http://jsfiddle.net/dmethvin/HG2v2/

Works in IE8, Safari 5, Chrome 7, Firefox 3.5.

comment:7 Changed 9 years ago by dmethvin

Milestone: 1.3
Resolution: worksforme
Status: closedreopened

comment:8 Changed 9 years ago by dmethvin

Keywords: $.ajax 404 event error problem removed
Priority: majorhigh
Status: reopenedopen
Summary: Jquery $.ajax event error problem$.ajax error on 404 in IE
Version: 1.2.61.4.4

Whoops, it does break on IE8.

comment:9 Changed 9 years ago by Rick Waldron

Keywords: ajaxrewrite added

comment:10 Changed 9 years ago by jaubourg

Resolution: fixed
Status: openclosed

Fixes #2994. Not finding a transport now fires the error callbacks and doesn't make ajax return false. Had to revise how jsonp and script prefilters & transports work (better separation of concerns). Also took the opportunity to revise jXHR getRequestHeader and abort methods and enabled early transport garbage collection when the request completes.

Changeset: 8ab23aec2c333834a6e442fa15b73125ba857afe

comment:11 Changed 9 years ago by jitter

Keywords: ajaxrewrite removed
Milestone: 1.5
Note: See TracTickets for help on using tickets.