]> source.dussan.org Git - jquery.git/commitdiff
Fixing request data param issue. Thanks to mislav for the patch. Fixes #5123.
authorjeresig <jeresig@gmail.com>
Tue, 15 Jun 2010 03:08:28 +0000 (23:08 -0400)
committerjeresig <jeresig@gmail.com>
Tue, 15 Jun 2010 03:08:28 +0000 (23:08 -0400)
src/ajax.js
test/data/echoData.php [new file with mode: 0644]
test/unit/ajax.js

index 47f243e55a4492f0126835a602b627132e45cf27..2c4f13cb2c3b1992b19863668432b34ec7ee1f81 100644 (file)
@@ -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 (file)
index 0000000..a37ba51
--- /dev/null
@@ -0,0 +1 @@
+<?php echo file_get_contents('php://input'); ?>
index fe44ba3b619ca88f92efbca238d7f441e8f4e440..8e3c4b67072d08f28a4a1d1a426542c721d20d61 100644 (file)
@@ -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 );