Skip to content

Commit 1d3d2b1

Browse files
committed
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
1 parent 4b3e630 commit 1d3d2b1

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/ajax/load.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ jQuery.fn.load = function( url, params, callback ) {
4646
jQuery.ajax({
4747
url: url,
4848

49-
// if "type" variable is undefined, then "GET" method will be used
50-
type: type,
49+
// If "type" variable is undefined, then "GET" method will be used.
50+
// Make value of this field explicit since
51+
// user can override it through ajaxSetup method
52+
type: type || "GET",
5153
dataType: "html",
5254
data: params
5355
}).done(function( responseText ) {

test/data/ajax/method.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo $_SERVER['REQUEST_METHOD'] ?>

test/unit/ajax.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,11 +1689,22 @@ module( "ajax", {
16891689
ok( false, "Global event triggered" );
16901690
});
16911691

1692-
jQuery("#qunit-fixture").append("<script src='data/evalScript.php'></script>");
1692+
jQuery("#qunit-fixture").append("<script src='data/ajax/evalScript.php'></script>");
16931693

16941694
jQuery( document ).off("ajaxStart ajaxStop");
16951695
});
16961696

1697+
asyncTest( "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)", 1, function() {
1698+
jQuery.ajaxSetup({
1699+
type: "POST"
1700+
});
1701+
1702+
jQuery( "#qunit-fixture" ).load( "data/ajax/method.php", function( method ) {
1703+
equal( method, "GET" );
1704+
start();
1705+
});
1706+
});
1707+
16971708
asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() {
16981709
jQuery("#qunit-fixture").load( "data/cleanScript.html", start );
16991710
});

0 commit comments

Comments
 (0)