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
?
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.
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.
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.
Use just setTimeout(executeQuery, 5000); instead of setTimeout('executeQuery()', 5000); - it's shorter and faster.
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 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With