Skip to main content

Bug Tracker

Side navigation

#15160 closed bug (migrated)

Opened June 21, 2014 04:47PM UTC

Closed October 21, 2014 12:40AM UTC

ajaxError and ajaxComplete firing twice upon abort

Reported by: Dwelle Owned by:
Priority: low Milestone: None
Component: ajax Version: 1.11.1
Keywords: ajax, abort, event Cc:
Blocked by: Blocking:
Description

Aborting

jqXHR
objects inside
ajaxSend
results in
ajaxError
and
ajaxComplete
callbacks being called twice. On first execution,
jqXHR
's status is
"abort"
, on second execution, it throws

TypeError: Cannot read property 'send' of undefined 
.

JSFiddle: http://jsfiddle.net/LK2g3/

tested on Chrome 35, FF 30, jQuery 1.9.1, 1.11.1, 2.1.1

Attachments (0)
Change History (3)

Changed June 22, 2014 11:19PM UTC by dmethvin comment:1

priority: undecidedlow
status: newopen
version: 1.9.11.11.1

Looks like this has been around for a while. Aborting happens synchronously and cleans up the request to avoid memory bloat. Then when it gets back from the ajaxSend it actually tries to send the request and the XHR object was blown out from under it.

Aborting the request doesn't make a lot of sense at that point, you can see from the XHR spec that it's pretty much a no-op if called before a .send(). So it seems more appropriate to have ajaxSend indicate that it doesn't want the request to proceed in some other way. The concern I'd have with making a change there would be compat. At least we know aborting doesn't currently work.

I'll mark this open for discussion.

Changed July 14, 2014 08:58AM UTC by Azriel comment:2

I've opened a PR with a suggested solution to this here: https://github.com/jquery/jquery/pull/1619

Changed October 21, 2014 12:40AM UTC by m_gol comment:3

resolution: → migrated
status: openclosed