mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Calling load with null as the data parameter now properly issues a GET request, not a POST request. Unit tests added. Fixes #12234.
This commit is contained in:
parent
aa1350d9e2
commit
b292c4c2df
@ -170,7 +170,7 @@ jQuery.fn.load = function( url, params, callback ) {
|
||||
params = undefined;
|
||||
|
||||
// Otherwise, build a param string
|
||||
} else if ( typeof params === "object" ) {
|
||||
} else if ( params && typeof params === "object" ) {
|
||||
type = "POST";
|
||||
}
|
||||
|
||||
|
@ -1037,11 +1037,45 @@ test("global ajaxSettings", function() {
|
||||
*/
|
||||
|
||||
test("load(String)", function() {
|
||||
expect(1);
|
||||
expect(2);
|
||||
stop(); // check if load can be called with only url
|
||||
jQuery.ajaxSetup({
|
||||
beforeSend: function() {
|
||||
strictEqual( this.type, "GET", "no data means GET request" );
|
||||
}
|
||||
});
|
||||
jQuery("#first").load("data/name.html", function() {
|
||||
start();
|
||||
});
|
||||
jQuery.ajaxSetup({
|
||||
beforeSend: null
|
||||
});
|
||||
});
|
||||
|
||||
test("load(String,null)", function() {
|
||||
expect(2);
|
||||
stop(); // check if load can be called with url and null data
|
||||
jQuery.ajaxSetup({
|
||||
beforeSend: function() {
|
||||
strictEqual( this.type, "GET", "no data means GET request" );
|
||||
}
|
||||
});
|
||||
jQuery("#first").load("data/name.html", null, function() {
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("load(String,undefined)", function() {
|
||||
expect(2);
|
||||
stop(); // check if load can be called with url and null data
|
||||
jQuery.ajaxSetup({
|
||||
beforeSend: function() {
|
||||
strictEqual( this.type, "GET", "no data means GET request" );
|
||||
}
|
||||
});
|
||||
jQuery("#first").load("data/name.html", undefined, function() {
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("load('url selector')", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user