Skip to content
Permalink
Browse files

jquery.ajax: improvement for #2688, added test

  • Loading branch information
jzaefferer committed Apr 22, 2008
1 parent 32b1cb3 commit e454e8305d7c159c3bcffafeb09ea98b342777ad
Showing with 23 additions and 5 deletions.
  1. +2 −5 src/ajax.js
  2. +21 −0 test/unit/ajax.js
@@ -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() {

0 comments on commit e454e83

Please sign in to comment.
You can’t perform that action at this time.