Bug Tracker

Modify

Ticket #6037 (closed bug: duplicate)

Opened 4 years ago

Last modified 2 years ago

oldAbort.call( xhr ) breaks in IE7 even within try/catch

Reported by: bpottle Owned by:
Priority: major Milestone: 1.4.2
Component: ajax Version: 1.4.1
Keywords: Cc:
Blocking: Blocked by:

Description

Still hunting for the source of this bug in the existing code -- might be better off putting together a barebones proof. I'll see if I can get that together.

ajax.js (line 463):

try {
	var oldAbort = xhr.abort;
	xhr.abort = function() {
		if ( xhr ) {
			oldAbort.call( xhr ); // <-- *DIES HERE*
		}
			onreadystatechange( "abort" );
	};
} catch(e) { }

Basically, in IE7 only, this line throws the error "Object does not support this property or method." IE8 is unaffected. Interestingly, Firefox with the latest version of Firebug will constantly show "200 Aborted" as the status for 90% of my $.ajax() calls when using jQuery 1.4.1 (even though they complete successfully and return my data), but when I comment this line out, they immediately start giving "200 OK" instead.

Additional question: Why does this error get thrown at all when wrapped in a try/catch like it is?

Also worth noting that there was a previous ticket on this block of code that errored on an attempt to set readyState in IE. It appears that was changed in 1.4.1.

Attachments

test.html Download (917 bytes) - added by geki007 4 years ago.
the client test file
test.php Download (32 bytes) - added by geki007 4 years ago.
the server testfile (to get an timeout)
test_abort.html Download (1.3 KB) - added by Nick M 4 years ago.
test_abort1.php Download (57 bytes) - added by Nick M 4 years ago.
test_abort2.php Download (57 bytes) - added by Nick M 4 years ago.

Change History

comment:1 Changed 4 years ago by john

I haven't been able to reproduce this on my end - do you have any more information about what might be going on?

comment:2 Changed 4 years ago by bpottle

Sorry, something shiny ran by and I got distracted for a few days. I got partway through putting together a proof for this; I'll see if I can finish it and get it posted soon.

comment:3 Changed 4 years ago by bpottle

I was able to strip down my page to barebones elements and narrow down the cause of this error.

It appears it lies not with jQuery 1.4.1, but the jquery.ajaxmanager.js plugin. I'm going to continue to investigate, but this ticket can be closed.

comment:4 Changed 4 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

Thanks for clearing this up, I appreciate it!

comment:5 Changed 4 years ago by geki007

  • Status changed from closed to reopened
  • Resolution invalid deleted

I have the same error in IE7 (not chrome, not firefox, not IE8). I used jquery 1.4.2. See my testcase. I fixed the error with another try catch around the if block:

xhr.abort = function() {

try {

if ( xhr ) {

oldAbort.call( xhr );

}

} catch(e) { }

}

Changed 4 years ago by geki007

the client test file

Changed 4 years ago by geki007

the server testfile (to get an timeout)

comment:6 Changed 4 years ago by Nick M

I've also encountered the same issue in IE7 (IE6 and IE8 don't seem to be affected).

However, the suggested fix of wrapping the if statement in another try block doesn't always seem to do the trick. If you have a callback on the request's completion that interacts with the response at all (eg, just checking "res.status" on the XMLHttpRequest object passed to complete()), IE7 will throw an "Unpsecified error" and completely ignore your abort call. I'll attach test case files that demonstrate this if you attempt to fix it with the extra try block.

It seems like everything works as expected in IE7 if you never attempt to override the abort method at all.

Changed 4 years ago by Nick M

Changed 4 years ago by Nick M

Changed 4 years ago by Nick M

comment:7 Changed 4 years ago by snover

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

Duplicate of #7018.

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.