Don't set the context in .load() as it stops the global ajax events from firing. Fixes #5922.
This commit is contained in:
parent
6a3d0996ed
commit
c639405c4d
|
@ -45,18 +45,19 @@ jQuery.fn.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
// Request the remote document
|
// Request the remote document
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: type,
|
type: type,
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
data: params,
|
data: params,
|
||||||
context:this,
|
|
||||||
complete: function( res, status ) {
|
complete: function( res, status ) {
|
||||||
// If successful, inject the HTML into all the matched elements
|
// If successful, inject the HTML into all the matched elements
|
||||||
if ( status === "success" || status === "notmodified" ) {
|
if ( status === "success" || status === "notmodified" ) {
|
||||||
// See if a selector was specified
|
// See if a selector was specified
|
||||||
this.html( selector ?
|
self.html( selector ?
|
||||||
// Create a dummy div to hold the results
|
// Create a dummy div to hold the results
|
||||||
jQuery("<div />")
|
jQuery("<div />")
|
||||||
// inject the contents of the document in, removing the scripts
|
// inject the contents of the document in, removing the scripts
|
||||||
|
@ -71,7 +72,7 @@ jQuery.fn.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( callback ) {
|
if ( callback ) {
|
||||||
this.each( callback, [res.responseText, status, res] );
|
self.each( callback, [res.responseText, status, res] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,6 +70,30 @@ test("jQuery.ajax() - error callbacks", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(".load()) - 404 error callbacks", function() {
|
||||||
|
expect( 6 );
|
||||||
|
stop();
|
||||||
|
|
||||||
|
jQuery('#foo').ajaxStart(function(){
|
||||||
|
ok( true, "ajaxStart" );
|
||||||
|
}).ajaxStop(function(){
|
||||||
|
ok( true, "ajaxStop" );
|
||||||
|
start();
|
||||||
|
}).ajaxSend(function(){
|
||||||
|
ok( true, "ajaxSend" );
|
||||||
|
}).ajaxComplete(function(){
|
||||||
|
ok( true, "ajaxComplete" );
|
||||||
|
}).ajaxError(function(){
|
||||||
|
ok( true, "ajaxError" );
|
||||||
|
}).ajaxSuccess(function(){
|
||||||
|
ok( false, "ajaxSuccess" );
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery("<div/>").load("data/404.html", function(){
|
||||||
|
ok(true, "complete");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("jQuery.ajax() - abort", function() {
|
test("jQuery.ajax() - abort", function() {
|
||||||
expect( 6 );
|
expect( 6 );
|
||||||
stop();
|
stop();
|
||||||
|
|
Loading…
Reference in a new issue