Permalink
Browse files

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 4ef120d
  • Loading branch information...
markelog committed Feb 14, 2015
1 parent 4b3e630 commit 1d3d2b1aa6bcd4de9e3a2d16f98685ac8726311c
Showing with 17 additions and 3 deletions.
  1. +4 −2 src/ajax/load.js
  2. 0 test/data/{ → ajax}/evalScript.php
  3. +1 −0 test/data/ajax/method.php
  4. +12 −1 test/unit/ajax.js
View
@@ -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 ) {
File renamed without changes.
@@ -0,0 +1 @@
+<?php echo $_SERVER['REQUEST_METHOD'] ?>
View
@@ -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 );
});

0 comments on commit 1d3d2b1

Please sign in to comment.