Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6725 closed bug (invalid)

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 (last modified by dmethvin)

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) { }

Change History (4)

comment:1 Changed 9 years ago by lobo235

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

comment:2 Changed 9 years ago by dmethvin

Description: modified (diff)

Can you provide a test case that demonstrates the bug?

comment:3 Changed 9 years ago by addyosmani

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.

comment:4 Changed 9 years ago by miguelmail2006@…

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

Note: See TracTickets for help on using tickets.