diff options
author | jeresig <jeresig@gmail.com> | 2010-01-12 10:31:51 -0500 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-01-12 10:31:51 -0500 |
commit | 7afe6dcc0837ac00cea7fbb7de6fb95b745148c2 (patch) | |
tree | 01c03d13f27c4f53614fd8406d6913caa3d43823 | |
parent | 4151ddef9d912ea48a404cfe4a0cf439a1f46815 (diff) | |
download | jquery-7afe6dcc0837ac00cea7fbb7de6fb95b745148c2.tar.gz jquery-7afe6dcc0837ac00cea7fbb7de6fb95b745148c2.zip |
Make sure that Opera fires events after an aborted Ajax attempt. Fixes #5787.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/ajax.js | 20 |
2 files changed, 20 insertions, 2 deletions
@@ -57,7 +57,7 @@ ${JQ}: ${MODULES} sed 's/Date:./&'"${DATE}"'/' | \ ${VER} > ${JQ}; -selector: init +selector: @@echo "Building selector code from Sizzle" @@sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js diff --git a/src/ajax.js b/src/ajax.js index 193a85ae0..07e706c4c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -393,7 +393,9 @@ jQuery.extend({ // The request was aborted, clear the interval and decrement jQuery.active if ( !xhr || xhr.readyState === 0 ) { requestDone = true; - xhr.onreadystatechange = jQuery.noop; + if ( xhr ) { + xhr.onreadystatechange = jQuery.noop; + } // Handle the global AJAX counter if ( s.global && ! --jQuery.active ) { @@ -447,6 +449,22 @@ jQuery.extend({ } }; + // 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() { + oldAbort.call( xhr ); + if ( xhr ) { + xhr.readyState = 0; + } + if ( !requestDone ) { + complete(); + } + onreadystatechange(); + }; + } catch(e) { } + // Timeout checker if ( s.async && s.timeout > 0 ) { setTimeout(function() { |