views:

189

answers:

4

This is from jQuery API docs:

typeString Default: 'GET' 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.

I am going to make AJAX delete links with jQuery. What I would like to know is specifics about browser support for DELETE and PUT. Which browsers support it? Is it safer that I just go with POST?

Given that I work in ASP.NET MVC I can decorate my controller actions with both DELETE and POST so both can be accepted.

+3  A: 

Go with POST. You don't have to worry about browser support and future maintainers of your code will understand whats going on just fine.

jfar
Not just browser support, but also server support. DELETE isn't commonly seen outside of WebDAV ( http://en.wikipedia.org/wiki/Webdav )
R. Bemrose
A: 

If all you're doing is deleting an item with a certain ID, GET should suit your purposes: http://www.diffen.com/difference/Get_vs_Post

Just make sure you handle a case where someone tries to delete something that's already deleted

statichippo
GET is a **bad** thing to do when your URLs manipulate some persistent store like a DB. What if a search engine followed it?
Mehrdad Afshari
No way for GET. Security risks.
mare
You shouldn't do a delete via GET, that implies that no data is modified...
Nate Bross
well presumably this is for authenticated users, right?
statichippo
+1  A: 

You could go with POST then set a form field named X-HTTP-Method-Override to DELETE.

See SO question #467535 for specific examples:

http://stackoverflow.com/questions/467535/is-it-possible-to-implement-x-http-method-override-in-asp-net-mvc

thomask
That answer is out of date. This is built into MVC 2.
Craig Stuntz
A: 

Extract from form value and send request, call Html.HttpMethodOverride(HttpVerbs.Delete) in form.

takepara