Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use POST or DELETE verb in jQuery.ajax() function

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.

like image 312
mare Avatar asked Oct 26 '22 20:10

mare


2 Answers

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.

like image 155
John Farrell Avatar answered Nov 15 '22 06:11

John Farrell


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

See SO question #467535 for specific examples:

Is it possible to implement X-HTTP-Method-Override in ASP.NET MVC?

like image 42
Thomas Kjørnes Avatar answered Nov 15 '22 05:11

Thomas Kjørnes