aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-02-15 01:25:02 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-02-15 02:03:32 +0300
commit1d3d2b1aa6bcd4de9e3a2d16f98685ac8726311c (patch)
tree1ceb6709aa61324c0a8f22800e4096f656d22136
parent4b3e63066dd480d07b9ce8057cb0c02b8ad7e990 (diff)
downloadjquery-1d3d2b1aa6bcd4de9e3a2d16f98685ac8726311c.tar.gz
jquery-1d3d2b1aa6bcd4de9e3a2d16f98685ac8726311c.zip
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 Ref 4ef120d3f2578fe3d52eb6c0d0641df945991391
-rw-r--r--src/ajax/load.js6
-rw-r--r--test/data/ajax/evalScript.php (renamed from test/data/evalScript.php)0
-rw-r--r--test/data/ajax/method.php1
-rw-r--r--test/unit/ajax.js13
4 files changed, 17 insertions, 3 deletions
diff --git a/src/ajax/load.js b/src/ajax/load.js
index e2f19affc..9d868a5dd 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
index ea9b8c55f..ea9b8c55f 100644
--- a/test/data/evalScript.php
+++ b/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 @@
+<?php echo $_SERVER['REQUEST_METHOD'] ?>
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index d048fdad9..718ddaf82 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("<script src='data/evalScript.php'></script>");
+ jQuery("#qunit-fixture").append("<script src='data/ajax/evalScript.php'></script>");
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 );
});