handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
- s.error.call( s.context || window, xhr, status, e );
+ s.error.call( s.context || s, xhr, status, e );
}
// Fire the global callback
});
test("Ajax events with context", function() {
- expect(6);
+ expect(14);
stop();
var context = document.createElement("div");
equals( this, context, e.type );
}
- function callback(){
- equals( this, context, "context is preserved on callback" );
+ function callback(msg){
+ return function(){
+ equals( this, context, "context is preserved on callback " + msg );
+ };
+ }
+
+ function nocallback(msg){
+ return function(){
+ equals( typeof this.url, "string", "context is settings on callback " + msg );
+ };
}
jQuery('#foo').add(context)
jQuery.ajax({
url: url("data/name.html"),
- beforeSend: callback,
- success: callback,
- error: callback,
+ beforeSend: callback("beforeSend"),
+ success: callback("success"),
+ error: callback("error"),
complete:function(){
- callback.call(this);
- setTimeout(proceed, 300);
+ callback("complete").call(this);
+
+ jQuery.ajax({
+ url: url("data/404.html"),
+ context: context,
+ beforeSend: callback("beforeSend"),
+ error: callback("error"),
+ complete: function(){
+ callback("complete").call(this);
+
+ jQuery('#foo').add(context).unbind();
+
+ jQuery.ajax({
+ url: url("data/404.html"),
+ beforeSend: nocallback("beforeSend"),
+ error: nocallback("error"),
+ complete: function(){
+ nocallback("complete").call(this);
+ start();
+ }
+ });
+ }
+ });
},
context:context
});
-
- function proceed(){
- jQuery('#foo').add(context).unbind();
- start();
- }
});
test("jQuery.ajax() - disabled globals", function() {