Data argument no longer works with DELETE requests
jQuery assumes DELETE requests will have no data, and so doesn't even look.
by malibu
HTML
<?php
// if PUT or DELETE output data received
if ( $_SERVER['REQUEST_METHOD'] == 'PUT' || $_SERVER['REQUEST_METHOD'] == 'DELETE' ) :
echo file_get_contents('php://input');
// otherwise return example page
else :
?>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.js"></script>
<script type="text/javascript">
function test(method)
{
$.ajax({
// request itself
url: '<?=$_SERVER['REQUEST_URI']?>',
// use passed method
type: method,
// sample data
data: {
hello: 'world',
usingMethod: method
},
// show user the results
success: function(data)
{
console.log('Method: ' + method + '\nResult: ' + data);
alert('Method: ' + method + '\nResult: ' + data);
}
});
}
// test put (for control)
test('put');
// test delete to highlight problem
test('delete');
</script>
</head>
<body>
Bug Test Case
</body>
</html>
<?php
endif;
?>
JavaScript
// IMPORTANT
// jsFiddle does not support testing ajax DELETE requests. Therefore:
// This is a standalone PHP/JS test to be run by the user ELSEWHERE.
// It is on jsFiddle because direct posting was flagged by Akismet.
// Additional Info
// A little test case up that requires PHP to run.
// All it does is echo back the data received, showing that while
// there is no problem with PUT, DELETE never sends it's data.