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

This commit is contained in:
jeresig 2010-06-14 23:08:28 -04:00
parent c34a62f8ab
commit c90d609c0d
3 changed files with 15 additions and 1 deletions

View 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 );

1
test/data/echoData.php Normal file
View file

@ -0,0 +1 @@
<?php echo file_get_contents('php://input'); ?>

View 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 );