Reputation: 3502
I am calling a API Delete function it accept only DELETE verb.
I have tried
$.ajax({
url: 'http://myurl',
type: 'DELETE',
success: function(result) {
// Do something with the result
});
But It shows Request Method as OPTIONS in Response Header.
Can anybody help me how i can send DELETE verb with ajax request.
Upvotes: 2
Views: 3745
Reputation: 3502
I got the best solution for this problem
http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/
add entry in webconfig
<modules runAllManagedModulesForAllRequests="true">
<add name="CorsHttpModule" type="Thinktecture.IdentityModel.Http.Cors.IIS.CorsHttpModule"/>
</modules>
Upvotes: 0
Reputation: 7141
"...But It shows Request Method as OPTIONS in Response Header."
It sounds like a cross domain request issue. Are you making the request from the same domain, or a different domain? And furthermore, what's the response? I'm also guessing that there isn't a second request, because the second request would essentially be your original request if the browser determined you can send that request from the options response. The options request is the browser asking if it can make this other request. The options response essentially tells the browser from which domains certain requests can be made (or something along those lines).
Read more about Cross-Origin Resource Sharing here
Upvotes: 2
Reputation: 9967
Here is your answer, enjoy : Are the PUT, DELETE, HEAD, etc methods available in most web browsers?
Per jQuery docs :
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
What browser are you using?
Upvotes: 1