BlueBockser BlueBockser - 6 months ago 37
PHP Question

jQuery AJAX PUT request data submission not working

I have a PHP file which contains the following:

echo '{ "response": "' . $_REQUEST['id'] . '" }';

Now I want to make an AJAX call to this file via jQuery:

var send = {
id: 10

data: send,
method: 'PUT',
url: "myphpfile.php",
success: function(responseData) {

This should return
as a response, however the output is empty. In the PHP file I also tried writing the id to a text file, which turned out to be empty as well. This means that my PHP code isn't the problem here, it's JavaScript.

When I change the AJAX url to
however, the response is correct and
is logged to the console.

I have tried a lot of things to fix this, nothing worked. This includes setting
contentType: 'application/json; charset=utf-8'
dataType: 'json'
data: JSON.stringify(send)
. I can't find any more forum questions or articles on this and the ones I found didn't work.

Any help is appreciated.


You cant access the data from a PUT request via $_REQUEST. You'd need something like:


    echo json_encode(['response'=>$sent_vars['id']]);

See also Accessing Incoming PUT Data from PHP