From 6bed348a007f8467dfc09cf63a1783bce673c3f4 Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 1 May 2012 14:39:45 -0400 Subject: [PATCH] jQuery.ajaxSetup() data is merged with params. Fixes #10524 --- src/ajax.js | 1 - test/unit/ajax.js | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 3de192766..b5d4865ff 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -183,7 +183,6 @@ jQuery.fn.extend({ // Otherwise, build a param string } else if ( typeof params === "object" ) { - params = jQuery.param( params, jQuery.ajaxSettings.traditional ); type = "POST"; } } diff --git a/test/unit/ajax.js b/test/unit/ajax.js index cca72aa5c..ede6d0f66 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1257,6 +1257,24 @@ test("load(String, String, Function)", function() { }); }); +asyncTest("load() - #10524", 1, function() { + jQuery.ajaxSetup({ + data: { foo: "bar" } + }); + + var data = { + baz: 1 + }; + + jQuery("#foo").load( "data/echoQuery.php", data).ajaxComplete(function( event, jqXHR, options ) { + ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" ); + jQuery.ajaxSetup({ + data: null + }); + start(); + }); +}); + test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() { expect(1); stop(); @@ -2411,4 +2429,4 @@ test("jQuery.ajax - active counter", function() { ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active ); }); -} \ No newline at end of file +}