Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11555 closed bug (notabug)

jQuery.ajaxTransport.send.callback doesn't get called for readyState = 2 with Chrome

Reported by: mbeelen@… Owned by: mbeelen@…
Priority: low Milestone: None
Component: ajax Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

In my application I make a call to the server using a jQuery.post().

My application sometimes returns a HttpResponse with status 406 in case the data provided in the request isn't acceptable. The response also contains additional HttpResponse headers, which contain an application specific errorCode and message. In my application I want to use the global ajaxError for reading the headers and inform the user about what went wrong.

In IE and Firefox this works fine, but in Chrome and Safari it fails. After doing some debuging I notice the main difference are the values of the jqXHR. In IE and FF the status will be 406 but reading the value in Chrome will return 0 and the responseHeaderString remains empty.

I notice that these values are being read from the standard xhr in the callback of ajaxTransport.send. (Starting from line 8105)

By putting a breakpoint within that callback I noticed that in Firefox the execution will hit the breakpoint twice: Once with readyState = 2 and once with readyState = 4. For some caching purpose jQuery will only read the headers when the readyState = 2.

In Chrome the breakpoint will only be hit once and the readyState = 4 at that moment, which results in the information of the headers not being present for my application, due to the caching of headers.

Change History (5)

comment:1 Changed 7 years ago by Rick Waldron

Component: unfiledajax
Owner: set to jaubourg
Priority: undecidedlow
Status: newassigned

comment:2 Changed 7 years ago by jaubourg

Owner: changed from jaubourg to mbeelen@…

I'd love to see a reduced test case for this, given we don't do anything for readyState 2 in jQuery, only readyState 4, so I'm a bit lost here.

comment:3 Changed 7 years ago by anonymous

Uncaught ReferenceError: calisan_listele is not defined $.ajax.success jQuery.Callbacks.fire jquery-1.7.2.js:1075 jQuery.Callbacks.self.fireWith jquery-1.7.2.js:1193 done jquery-1.7.2.js:7538 jQuery.ajaxTransport.send.callback

comment:4 in reply to:  3 Changed 7 years ago by jaubourg

Replying to anonymous:

Uncaught ReferenceError: calisan_listele is not defined $.ajax.success jQuery.Callbacks.fire jquery-1.7.2.js:1075 jQuery.Callbacks.self.fireWith jquery-1.7.2.js:1193 done jquery-1.7.2.js:7538 jQuery.ajaxTransport.send.callback

That's not a test case. And calisan_listele is not used in jQuery, the error is thrown from your own callback (ie. your own code).

comment:5 Changed 7 years ago by jaubourg

Resolution: notabug
Status: assignedclosed
Note: See TracTickets for help on using tickets.