Skip to content

Commit

Permalink
Make sure that Opera fires events after an aborted Ajax attempt. Fixe…
Browse files Browse the repository at this point in the history
…s #5787.
  • Loading branch information
jeresig committed Jan 12, 2010
1 parent 4151dde commit 7afe6dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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

Expand Down
20 changes: 19 additions & 1 deletion src/ajax.js
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 7afe6dc

Please sign in to comment.