From: jeresig <jeresig@gmail.com>
Date: Tue, 15 Jun 2010 03:08:28 +0000 (-0400)
Subject: Fixing request data param issue. Thanks to mislav for the patch. Fixes #5123.
X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=c90d609c0d10a8792b0b31e226592fd707f45570;p=jquery.git

Fixing request data param issue. Thanks to mislav for the patch. Fixes #5123.
---

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 @@
+<?php echo file_get_contents('php://input'); ?>
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 );