Skip to content

Commit c90d609

Browse files
committed
Fixing request data param issue. Thanks to mislav for the patch. Fixes jquery#5123.
1 parent c34a62f commit c90d609

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ jQuery.extend({
484484

485485
// Send the data
486486
try {
487-
xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
487+
xhr.send( (type !== "GET" && s.data) || null );
488488

489489
} catch( sendError ) {
490490
jQuery.ajax.handleError( s, xhr, null, e );

test/data/echoData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo file_get_contents('php://input'); ?>

test/unit/ajax.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,19 @@ test("data option: evaluate function values (#2806)", function() {
11631163
})
11641164
});
11651165

1166+
test("data option: empty bodies for non-GET requests", function() {
1167+
stop();
1168+
jQuery.ajax({
1169+
url: "data/echoData.php",
1170+
data: undefined,
1171+
type: "post",
1172+
success: function(result) {
1173+
equals( result, "" );
1174+
start();
1175+
}
1176+
})
1177+
});
1178+
11661179
test("jQuery.ajax - If-Modified-Since support", function() {
11671180
expect( 3 );
11681181

0 commit comments

Comments
 (0)