From 4ef120d3f2578fe3d52eb6c0d0641df945991391 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Tue, 10 Feb 2015 22:42:21 +0300 Subject: [PATCH] Ajax: make jQuery#load "type" field explicit * Move "evalScript.php" file to appropriate place * Make jQuery#load "type" field explicit and add test for it Ref trac-11264 --- src/ajax/load.js | 6 ++++-- test/data/{ => ajax}/evalScript.php | 0 test/data/ajax/method.php | 1 + test/unit/ajax.js | 13 ++++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) rename test/data/{ => ajax}/evalScript.php (100%) create mode 100644 test/data/ajax/method.php diff --git a/src/ajax/load.js b/src/ajax/load.js index 2d56b704b..595061443 100644 --- a/src/ajax/load.js +++ b/src/ajax/load.js @@ -46,8 +46,10 @@ jQuery.fn.load = function( url, params, callback ) { jQuery.ajax({ url: url, - // if "type" variable is undefined, then "GET" method will be used - type: type, + // If "type" variable is undefined, then "GET" method will be used. + // Make value of this field explicit since + // user can override it through ajaxSetup method + type: type || "GET", dataType: "html", data: params }).done(function( responseText ) { diff --git a/test/data/evalScript.php b/test/data/ajax/evalScript.php similarity index 100% rename from test/data/evalScript.php rename to test/data/ajax/evalScript.php diff --git a/test/data/ajax/method.php b/test/data/ajax/method.php new file mode 100644 index 000000000..d76ff964b --- /dev/null +++ b/test/data/ajax/method.php @@ -0,0 +1 @@ + diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 29a4dfb46..20469d4e7 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1689,11 +1689,22 @@ module( "ajax", { ok( false, "Global event triggered" ); }); - jQuery("#qunit-fixture").append(""); + jQuery("#qunit-fixture").append(""); jQuery( document ).off("ajaxStart ajaxStop"); }); + asyncTest( "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)", 1, function() { + jQuery.ajaxSetup({ + type: "POST" + }); + + jQuery( "#qunit-fixture" ).load( "data/ajax/method.php", function( method ) { + equal( method, "GET" ); + start(); + }); + }); + asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { jQuery("#qunit-fixture").load( "data/cleanScript.html", start ); }); -- 2.39.5