Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ajaxError and ajaxComplete firing twice upon abort #1775
Originally reported by Dwelle at: http://bugs.jquery.com/ticket/15160
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 .
tested on Chrome 35, FF 30, jQuery 1.9.1, 1.11.1, 2.1.1
Issue reported for jQuery 1.11.1
Comment author: dmethvin
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.
Quite often we batch these things up and don't get serious about landing PRs until we start the push for a new version. If you've already signed our CLA you're in good shape and we will land it soon. Thanks for contributing!