Commit b292c4c2 authored by jaubourg's avatar jaubourg

Calling load with null as the data parameter now properly issues a GET...

Calling load with null as the data parameter now properly issues a GET request, not a POST request. Unit tests added. Fixes #12234.
parent aa1350d9
...@@ -170,7 +170,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -170,7 +170,7 @@ jQuery.fn.load = function( url, params, callback ) {
params = undefined; params = undefined;
// Otherwise, build a param string // Otherwise, build a param string
} else if ( typeof params === "object" ) { } else if ( params && typeof params === "object" ) {
type = "POST"; type = "POST";
} }
......
...@@ -1037,11 +1037,45 @@ test("global ajaxSettings", function() { ...@@ -1037,11 +1037,45 @@ test("global ajaxSettings", function() {
*/ */
test("load(String)", function() { test("load(String)", function() {
expect(1); expect(2);
stop(); // check if load can be called with only url 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() { jQuery("#first").load("data/name.html", function() {
start(); 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() { test("load('url selector')", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment