#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: | ||
Blocked by: | Blocking: |
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 (1)
Change History (13)
comment:1 Changed 13 years ago by
comment:2 Changed 12 years ago by
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 12 years ago by
Attachment: | 0001-Workaround-for-lack-of-call-method-in-IE.patch added |
---|
patch for call() workaround
comment:3 Changed 12 years ago by
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:5 Changed 12 years ago by
Milestone: | 1.4.2 |
---|---|
Owner: | set to laurensonyourscreen |
Priority: | → high |
Status: | new → pending |
Can you confirm the patch at 9b655a176b0d045c3773357761acf2fa93cd9650 resolves this issue or is this still malfunctioning?
comment:6 Changed 12 years ago by
Status: | pending → closed |
---|
Automatically closed due to 14 days of inactivity.
comment:7 follow-up: 8 Changed 12 years ago by
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 Changed 12 years ago by
Replying to [email protected]…:
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 12 years ago by
Keywords: | ajaxrewrite added; ajax xht dataType abort() removed |
---|---|
Status: | closed → reopened |
comment:11 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:12 Changed 12 years ago by
Keywords: | ajaxrewrite removed |
---|---|
Milestone: | → 1.4.3 |
Discussion here http://forum.jquery.com/topic/object-doesn-t-support-this-property-or-method-from-jquery-1-4-1-in-ie7-only