]> source.dussan.org Git - jquery.git/commitdiff
Calling load with null as the data parameter now properly issues a GET request, not...
authorjaubourg <j@ubourg.net>
Thu, 16 Aug 2012 14:45:18 +0000 (16:45 +0200)
committerjaubourg <j@ubourg.net>
Thu, 16 Aug 2012 14:45:18 +0000 (16:45 +0200)
src/ajax.js
test/unit/ajax.js

index f3887ff44a604e3906ea3b1a6592b4794e09e230..cfbfcd5272b2d92a52d683f7c753943598f8619d 100644 (file)
@@ -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";
        }
 
index 2371f898200381292e8edcbefe0f681d98b96666..1345eae3a73b51f15bf312791c4659d2a870b199 100644 (file)
@@ -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() {