diff --git a/src/ajax.js b/src/ajax.js index 47f243e55..2c4f13cb2 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 000000000..a37ba515a --- /dev/null +++ b/test/data/echoData.php @@ -0,0 +1 @@ + diff --git a/test/unit/ajax.js b/test/unit/ajax.js index fe44ba3b6..8e3c4b670 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 );