Commit 73c1ceaf authored by Dan Hart's avatar Dan Hart Committed by Timmy Willison

Ajax: Fix for request aborted in ajaxSend

Fixes gh-1775
Close gh-1619
parent 2a3018ce
...@@ -644,6 +644,12 @@ jQuery.extend({ ...@@ -644,6 +644,12 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
} }
// If request was aborted inside ajaxSend, stop there
if ( state === 2 ) {
return jqXHR;
}
// Timeout // Timeout
if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
timeoutTimer = setTimeout(function() { timeoutTimer = setTimeout(function() {
......
...@@ -435,6 +435,23 @@ module( "ajax", { ...@@ -435,6 +435,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, { ajaxTest( "jQuery.ajax() - context modification", 1, {
url: url("data/name.html"), url: url("data/name.html"),
context: {}, context: {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment