Ticket #6498 (closed bug: fixed)
XHR abort() method not working in IE7.
| Reported by: | laurensonyourscreen | Owned by: | laurensonyourscreen |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4.3 |
| Component: | ajax | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When you call the abort() method on a jQuery XHR object. IE7 will raise an error. The error IE7 (version 7.0.6001.18000 to be exact) is giving is:
"Object doesn't support this property or method (line 5233)"
Looking into the jQuery source, it seems to fail on this peace of code:
" Override the abort handler, if we can (IE doesn't allow it, but that's OK) Opera doesn't fire onreadystatechange at all on abort try {
var oldAbort = xhr.abort; xhr.abort = function() {
if ( xhr ) {
oldAbort.call( xhr ); <-- here!
}
onreadystatechange( "abort" );
};
} catch(e) {console.log(e) } "
To reproduce this in IE7, I used this: " var xhr = $.ajax({
url: ' http://samedomain.com/', dataType: 'json'
});
xhr.abort(); "
I know the issue does not raise in Firefox 3.6.3. But I haven't tested it in other browsers.
Attachments
Change History
comment:2 Changed 3 years ago by hallettj
Possibly the same issue as ticket #6314.
So, this portion of jQuery is written with the assumption that xhr.abort() cannot be reassigned in IE. However, it turns out that under some circumstances xhr.abort() can be reassigned in IE - but the xhr methods in IE do not support a call() method so IE crashes when it hits that method call.
This can be fixed by borrowing the call() method from Function.prototype:
try {
var oldAbort = xhr.abort;
xhr.abort = function() {
if ( xhr ) {
if (oldAbort.call) {
oldAbort.call( xhr );
} else {
Function.prototype.call.call(oldAbort, oldAbort, xhr);
}
}
onreadystatechange( "abort" );
};
} catch(e) { }
Changed 3 years ago by hallettj
-
attachment
0001-Workaround-for-lack-of-call-method-in-IE.patch
added
patch for call() workaround
comment:3 Changed 3 years ago by hallettj
Sorry, there was a mistake in the code in my last comment. The code is corrected in the attached patch. Here is what that code should have looked like:
try {
var oldAbort = xhr.abort;
xhr.abort = function() {
if ( xhr ) {
if (oldAbort.call) {
oldAbort.call( xhr );
} else {
Function.prototype.call.call(oldAbort, xhr);
}
}
onreadystatechange( "abort" );
};
} catch( abortError ) {}
comment:4 Changed 3 years ago by chrispruett
Confirmed that the above patch fixes this issue for me.
comment:5 Changed 3 years ago by snover
- Owner set to laurensonyourscreen
- Priority set to high
- Status changed from new to pending
- Milestone 1.4.2 deleted
Can you confirm the patch at 9b655a176b0d045c3773357761acf2fa93cd9650 resolves this issue or is this still malfunctioning?
comment:6 Changed 3 years ago by trac-o-bot
- Status changed from pending to closed
Automatically closed due to 14 days of inactivity.
comment:7 follow-up: ↓ 8 Changed 2 years ago by mleden@…
Hi,
I think I am running into this bug with jQuery 1.4.2. How can I tell in which version the fix will be included?
Thx, -Mark
comment:8 in reply to: ↑ 7 Changed 2 years ago by jitter
Replying to mleden@…:
Hi,
I think I am running into this bug with jQuery 1.4.2. How can I tell in which version the fix will be included?
Thx, -Mark
The commit snover linked to is included in 1.4.3. But you should try with the latest stable jQuery and maybe also the jQuery development version. Check http://docs.jquery.com/Downloading_jQuery for the links.
Can you then please report back here if the problem is fixed or if the issue remains request reopening and additionally provide a test case on http://jsfiddle.net showing the bug.
comment:10 Changed 2 years ago by rwaldron
- Keywords ajaxrewrite added; ajax xht dataType abort() removed
- Status changed from closed to reopened
comment:11 Changed 2 years ago by snover
- Status changed from reopened to closed
- Resolution set to fixed
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Discussion here http://forum.jquery.com/topic/object-doesn-t-support-this-property-or-method-from-jquery-1-4-1-in-ie7-only