Skip to main content

Bug Tracker

Side navigation

#6725 closed bug (invalid)

Opened June 25, 2010 08:17PM UTC

Closed October 12, 2010 05:09AM UTC

Last modified March 09, 2011 04:08PM UTC

Javascript error in IE7 when trying to abort an AJAX request

Reported by: lobo235 Owned by:
Priority: undecided Milestone: 1.4.3
Component: ajax Version: 1.4.2
Keywords: IE7 ajax abort Cc:
Blocked by: Blocking:
Description

Wen calling the .abort() method on the XMLHttpRequest that is returned by the $.ajax( ) method you will get a javascript error in IE7. I have written a fix for the problematic area and I have included it below:

Original 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 );
		}

		onreadystatechange( "abort" );
	};
} catch(e) { }

Fixed 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 && typeof oldAbort == 'function' ) {
			oldAbort.call( xhr );
		}

		onreadystatechange( "abort" );
	};
} catch(e) { }
Attachments (0)
Change History (4)

Changed June 25, 2010 08:18PM UTC by lobo235 comment:1

Please contact me if you need more details or have questions about the bug.

Changed June 25, 2010 09:36PM UTC by dmethvin comment:2

description: Wen calling the .abort() method on the XMLHttpRequest that is returned by the $.ajax( ) method you will get a javascript error in IE7. I have written a fix for the problematic area and I have included it below: \ \ Original 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 ); \ } \ \ onreadystatechange( "abort" ); \ }; \ } catch(e) { } \ \ Fixed 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 && typeof oldAbort == 'function' ) { \ oldAbort.call( xhr ); \ } \ \ onreadystatechange( "abort" ); \ }; \ } catch(e) { }Wen calling the .abort() method on the XMLHttpRequest that is returned by the $.ajax( ) method you will get a javascript error in IE7. I have written a fix for the problematic area and I have included it below: \ \ Original 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 ); \ } \ \ onreadystatechange( "abort" ); \ }; \ } catch(e) { } \ }}} \ Fixed 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 && typeof oldAbort == 'function' ) { \ oldAbort.call( xhr ); \ } \ \ onreadystatechange( "abort" ); \ }; \ } catch(e) { } \ }}}

Can you provide a test case that demonstrates the bug?

Changed October 12, 2010 05:09AM UTC by addyosmani comment:3

need: ReviewTest Case
priority: → undecided
resolution: → invalid
status: newclosed

As we requested a few months ago, please re-submit your original ticket with a complete test case that we can run so that we may more accurately establish the cause of the bug experienced.

Changed March 09, 2011 04:08PM UTC by miguelmail2006@gmail.com comment:4

Hi, excuse my ignorance but, where is defined on the script the onreadystatechange function? is not that the event over the xhr object? like xhr.onreadystatechange ?

Thanks