mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Ajax: execute jQuery#load callback with correct context
Thanks @blq (Fredrik Blomqvist) Fixes gh-3035 Close gh-3039
This commit is contained in:
parent
c158f5761a
commit
5d20a3c3f1
@ -62,7 +62,7 @@ jQuery.fn.load = function( url, params, callback ) {
|
||||
// If it fails, this function gets "jqXHR", "status", "error"
|
||||
} ).always( callback && function( jqXHR, status ) {
|
||||
self.each( function() {
|
||||
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
|
||||
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
@ -2084,6 +2084,25 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"jQuery#load() - should resolve with correct context", 2,
|
||||
function( assert ) {
|
||||
var done = assert.async();
|
||||
var ps = jQuery( "<p></p><p></p>" );
|
||||
var i = 0;
|
||||
|
||||
ps.appendTo( "#qunit-fixture" );
|
||||
|
||||
ps.load( "data/ajax/method.php", function() {
|
||||
assert.strictEqual( this, ps[ i++ ] );
|
||||
|
||||
if ( i === 2 ) {
|
||||
done();
|
||||
}
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"#11402 - jQuery.domManip() - script in comments are properly evaluated", 2,
|
||||
function( assert ) {
|
||||
|
Loading…
Reference in New Issue
Block a user