From c90d609c0d10a8792b0b31e226592fd707f45570 Mon Sep 17 00:00:00 2001 From: jeresig Date: Mon, 14 Jun 2010 23:08:28 -0400 Subject: [PATCH] Fixing request data param issue. Thanks to mislav for the patch. Fixes #5123. --- src/ajax.js | 2 +- test/data/echoData.php | 1 + test/unit/ajax.js | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/data/echoData.php diff --git a/src/ajax.js b/src/ajax.js index 47f243e..2c4f13c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -484,7 +484,7 @@ jQuery.extend({ // Send the data try { - xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); + xhr.send( (type !== "GET" && s.data) || null ); } catch( sendError ) { jQuery.ajax.handleError( s, xhr, null, e ); diff --git a/test/data/echoData.php b/test/data/echoData.php new file mode 100644 index 0000000..a37ba51 --- /dev/null +++ b/test/data/echoData.php @@ -0,0 +1 @@ + diff --git a/test/unit/ajax.js b/test/unit/ajax.js index fe44ba3..8e3c4b6 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1163,6 +1163,19 @@ test("data option: evaluate function values (#2806)", function() { }) }); +test("data option: empty bodies for non-GET requests", function() { + stop(); + jQuery.ajax({ + url: "data/echoData.php", + data: undefined, + type: "post", + success: function(result) { + equals( result, "" ); + start(); + } + }) +}); + test("jQuery.ajax - If-Modified-Since support", function() { expect( 3 ); -- 1.7.10.4