Ticket #6256 (closed bug: duplicate)
IE8 AJAX GET request fails due to unexpected call to abort handler
| Reported by: | ratbert | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.5 |
| Component: | ajax | Version: | 1.5 |
| Keywords: | abort, xhr | Cc: | snover, SlexAxton |
| Blocking: | Blocked by: |
Description
jquery 1.4.2 has the following code in the AJAX request handler:
Line 5229:
try {
var oldAbort = xhr.abort; xhr.abort = function() {
if ( xhr ) {
oldAbort.call( xhr );
}
onreadystatechange("abort");
};
} catch(e) { }
I'm no javascript expert, but the line "var oldAbort = xhr.abort;" doesn't look like a function call to me. On IE8 though it seems that the xhr.abort function is actually called and the xhr goes dead (ready state 1 -> 0) and the xhr.send() that follows then fails.
Hacking the line to "var oldAbort = null;" allows the xhr.send() to succeed and my AJAX request works.
Notes:
This is not a proposed fix - good luck with that ;)
This form of override of current handlers, or callbacks, or whatever, is not uncommon in jQuery I think. I wonder how many other case there are that IE8 barfs on... Thanks a lot microsoft.
Change History
comment:3 Changed 3 years ago by SlexAxton
- Status changed from new to closed
- Cc snover, SlexAxton added
- Priority set to undecided
- Milestone changed from 1.4.3 to 1.4.5
- Keywords abort, xhr added
- Resolution set to duplicate
This is a duplicate (notably of a newer bug), but since that one was marked as fixed. I'll mark this as such.
Does anyone have an opinion about calling oldAbort() like he does in the patch here? Is that safe? If anyone feels strongly about this, can you file an enhancement ticket for it? It'd be an easy addition.
The commit is here: https://github.com/jquery/jquery/commit/9b655a176b0d045c3773357761acf2fa93cd9650
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Hello,
here is a patch for this issue that works on all browsers and make .abort () work correctly on IE{6,7,8}.
--- a/jquery-1.4.2.js +++ b/jquery-1.4.2.js @@ -5230,7 +5230,10 @@ jQuery.extend({ var oldAbort = xhr.abort; xhr.abort = function() { if ( xhr ) { - oldAbort.call( xhr ); + if ( oldAbort.call !== undefined ) + oldAbort.call( xhr ); + else + oldAbort(); } onreadystatechange( "abort" );Against jquery.js 1.4.2.
Hope this helps,
~Marcello