Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass data in the ajax DELETE request other than headers

Tags:

jquery

ajax

Below is my Ajax request for a DELETE request:

deleteRequest: function (url, Id, bolDeleteReq, callback, errorCallback) {     $.ajax({         url: urlCall,         type: 'DELETE',         headers: {"Id": Id, "bolDeleteReq" : bolDeleteReq},         success: callback || $.noop,         error: errorCallback || $.noop     }); } 

Is there any alternative way to pass the data other than in the headers?

like image 282
Prats Avatar asked Feb 26 '13 12:02

Prats


People also ask

Can we pass data in delete request?

Sending a message body on a DELETE request might cause some servers to reject the request. But you still can send data to the server using URL parameters. This is usually an ID of the resource you want to delete.

How do you delete a request on ajax?

The working of the ajax delete request So we can use the ajax() function with type option as “$. ajax( 'http://time.jsontest.com', { type : “DELETE});”, where the first parameter is the URL of the data that to delete. So, if the request successful means that the specified data will get deleted.

Can we send data in ajax GET request?

In the options parameter, we have specified a type option as a POST, so ajax() method will send http POST request. Also, we have specified data option as a JSON object containing data which will be submitted to the server. So this way you can send GET, POST or PUT request using ajax() method.

How do you send ajax request every 5 seconds?

Use just setTimeout(executeQuery, 5000); instead of setTimeout('executeQuery()', 5000); - it's shorter and faster.


1 Answers

Read this Bug Issue: http://bugs.jquery.com/ticket/11586

Quoting the RFC 2616 Fielding

The DELETE method requests that the origin server delete the resource identified by the Request-URI.

So you need to pass the data in the URI

$.ajax({     url: urlCall + '?' + $.param({"Id": Id, "bolDeleteReq" : bolDeleteReq}),     type: 'DELETE',     success: callback || $.noop,     error: errorCallback || $.noop }); 
like image 106
Gabriele Petrioli Avatar answered Sep 22 '22 12:09

Gabriele Petrioli