mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
jquery.ajax: improvement for #2688, added test
This commit is contained in:
parent
32b1cb3a5c
commit
e454e8305d
@ -291,11 +291,8 @@ jQuery.extend({
|
||||
} catch(e){}
|
||||
|
||||
// Allow custom headers/mimetypes
|
||||
if ( s.beforeSend )
|
||||
var beforeSendSuccess = s.beforeSend(xml, s);
|
||||
|
||||
if( beforeSendSuccess === false )
|
||||
return false;
|
||||
if ( s.beforeSend && s.beforeSend(xml, s) === false )
|
||||
return false;
|
||||
|
||||
if ( s.global )
|
||||
jQuery.event.trigger("ajaxSend", [xml, s]);
|
||||
|
@ -136,6 +136,27 @@ test("$.ajax - beforeSend", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test("$.ajax - beforeSend, cancel request (#2688)", function() {
|
||||
expect(2);
|
||||
var request = $.ajax({
|
||||
url: url("data/name.html"),
|
||||
beforeSend: function() {
|
||||
ok( true, "beforeSend got called, canceling" );
|
||||
return false;
|
||||
},
|
||||
success: function() {
|
||||
ok( false, "request didn't get canceled" );
|
||||
},
|
||||
complete: function() {
|
||||
ok( false, "request didn't get canceled" );
|
||||
},
|
||||
error: function() {
|
||||
ok( false, "request didn't get canceled" );
|
||||
}
|
||||
});
|
||||
ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
|
||||
});
|
||||
|
||||
var foobar;
|
||||
|
||||
test("$.ajax - dataType html", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user