Permalink
Browse files

Ajax: Fix for request aborted in ajaxSend

Fixes gh-1775
Close gh-1619
  • Loading branch information...
Dan Hart authored and timmywil committed Jul 13, 2014
1 parent 31d58c5 commit 598ed050f6931922214aeaea8a1dc867e0cc6fb7
Showing with 23 additions and 0 deletions.
  1. +6 −0 src/ajax.js
  2. +17 −0 test/unit/ajax.js
View
@@ -627,6 +627,12 @@ jQuery.extend({
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
}
// If request was aborted inside ajaxSend, stop there
if ( state === 2 ) {
return jqXHR;
}
// Timeout
if ( s.async && s.timeout > 0 ) {
timeoutTimer = setTimeout(function() {
View
@@ -440,6 +440,23 @@ module( "ajax", {
};
});
ajaxTest( "#15160 - jQuery.ajax() - request manually aborted in ajaxSend", 3, {
setup: function() {
jQuery( document ).on( "ajaxSend", function( e, jqXHR ) {
jqXHR.abort();
});
jQuery( document ).on( "ajaxError ajaxComplete", function( e, jqXHR ) {
equal( jqXHR.statusText, "abort", "jqXHR.statusText equals abort on global ajaxComplete and ajaxError events" );
});
},
url: url("data/name.html"),
error: true,
complete: function() {
ok( true, "complete" );
}
});
ajaxTest( "jQuery.ajax() - context modification", 1, {
url: url("data/name.html"),
context: {},

0 comments on commit 598ed05

Please sign in to comment.