I want to send a HTTP DELETE like this:
$.ajax({
url: "http://localhost/myapp",
type: "DELETE",
data: {
"brown": "fox",
"lazy": "dog"
}
});
The problem is jquery puts the data into the body of the request. I want the data to be put in query string, like http://localhost/myapp?brown=fox&lazy=dog
.
Is there an option in $.ajax to do that? Or do I have to manually construct the query string?
jQuery 1.10.2.
UPDATE:
Context for my question:
$.ajax
$.ajax
CAN send HTTP DELETEThere is a discussion of this behaviour on jQuery's GitHub page: https://github.com/jquery/jquery/issues/3269
The solution is to append the query string to the URL manually. jQuery's $.param
function is helpful for this:
$.ajax({
type: "DELETE",
url: "http://localhost/myapp?" + $.param({
"brown": "fox",
"lazy": "dog"
})
});
Write your code like:
$.ajax({
url: "http://localhost/myapp?brown=fox&lazy=dog",
type: "DELETE",
success: function(result){
alert(result);
}
});
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