Bug Tracker

Modify

Ticket #6498 (closed bug: fixed)

Opened 4 years ago

Last modified 2 years ago

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

0001-Workaround-for-lack-of-call-method-in-IE.patch Download (739 bytes) - added by hallettj 4 years ago.
patch for call() workaround

Change History

comment:2 Changed 4 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 4 years ago by hallettj

patch for call() workaround

comment:3 Changed 4 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 4 years ago by chrispruett

Confirmed that the above patch fixes this issue for me.

comment:5 Changed 4 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?

Version 0, edited 4 years ago by snover (next)

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 3 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 3 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:9 Changed 3 years ago by anonymous

I can confirm jQuery 1.4.4 solves the problem

comment:10 Changed 3 years ago by rwaldron

  • Keywords ajaxrewrite added; ajax xht dataType abort() removed
  • Status changed from closed to reopened

comment:11 Changed 3 years ago by snover

  • Status changed from reopened to closed
  • Resolution set to fixed

comment:12 Changed 3 years ago by jitter

  • Keywords ajaxrewrite removed
  • Milestone set to 1.4.3

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.