Cleans up and simplifies code shared by ajaxPrefilter and ajaxTransport. Removes chainability of ajaxSetup, ajaxPrefilter and ajaxTransport. Also makes sure context is handled properly by ajaxSetup (unit test added).

This commit is contained in:
jaubourg 2011-01-20 04:12:15 +01:00
parent 96b00a4935
commit 64e1cdbb95
4 changed files with 139 additions and 114 deletions

View file

@ -599,6 +599,47 @@ test("jQuery.ajax context modification", function() {
equals( obj.test, "foo", "Make sure the original object is maintained." );
});
test("jQuery.ajax context modification through ajaxSetup", function() {
expect(4);
stop();
var obj = {};
jQuery.ajaxSetup({
context: obj
});
strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." );
jQuery.ajax({
url: url("data/name.html"),
complete: function() {
strictEqual( this, obj, "Make sure the original object is maintained." );
jQuery.ajax({
url: url("data/name.html"),
context: {},
complete: function() {
ok( this !== obj, "Make sure overidding context is possible." );
jQuery.ajaxSetup({
context: false
});
jQuery.ajax({
url: url("data/name.html"),
beforeSend: function(){
this.test = "foo2";
},
complete: function() {
ok( this !== obj, "Make sure unsetting context is possible." );
start();
}
});
}
});
}
});
});
test("jQuery.ajax() - disabled globals", function() {
expect( 3 );
stop();