Skip to main content

Bug Tracker

Side navigation

#11555 closed bug (notabug)

Opened April 04, 2012 02:43PM UTC

Closed October 16, 2012 06:59PM UTC

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

Reported by: mbeelen@iprofs.nl Owned by: mbeelen@iprofs.nl
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.

Attachments (0)
Change History (5)

Changed April 23, 2012 04:36PM UTC by rwaldron comment:1

component: unfiledajax
owner: → jaubourg
priority: undecidedlow
status: newassigned

Changed April 23, 2012 05:11PM UTC by jaubourg comment:2

owner: jaubourgmbeelen@iprofs.nl

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.

Changed August 01, 2012 12:46PM UTC by anonymous comment:3

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

Changed August 01, 2012 12:57PM UTC by jaubourg comment:4

Replying to [comment:3 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).

Changed October 16, 2012 06:59PM UTC by jaubourg comment:5

resolution: → notabug
status: assignedclosed