HTTP DELETE using jQuery ajax with parameters in query string
jquery
Solution
There 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"
})
});
Problem
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: - I know how to use jQuery's `$.ajax` - I know how to send HTTP DELETE request - jQuery's `$.ajax` CAN send HTTP DELETE - the server can receive my HTTP DELETE request just fine (put another way: I have successfully sent a HTTP DELETE request to the server, the only problem is that the server misinterpret my request because it turned out jquery put the parameters in the body of the request while the server expects the parameters in query string) - I am sending the request to a web service - I have to use HTTP DELETE because that's how the provider of the web service set up the service - the parameters must be in the query string because the provider will only read the parameters in the query string and will ignore the request body