How can I link to a page and make the browser call it with the DELETE method, as Rails does?
I tried <a href="DELETE /post?id=3">DELETE ME</a>
but doesn`t work.
I use Node.js, so I can use it to handle DELETE method.
Asked
Active
Viewed 1.0k times
8

Carlos Precioso
- 2,731
- 3
- 21
- 24
2 Answers
9
You can't. Links will only ever trigger a GET request.
You can choose between a GET and a POST in a form.
Other HTTP request types can be made using JavaScript and XMLHttpRequest, but not reliably cross-browser.

Quentin
- 914,110
- 126
- 1,211
- 1,335
-
4With some javascript magic: http://stackoverflow.com/questions/2809200/how-does-rails-3s-data-method-delete-degrade-gracefully – leonbloy Apr 28 '11 at 19:20
-
1rails can only handle them if they come.. but a link in a browser can not produce it yet.. jquery.ajax() method can – Alexander Taran Apr 28 '11 at 19:23
2
You can use a javascript plugin like RestfulizerJs for converting your links to pseudo forms.

Ifnot
- 4,914
- 4
- 33
- 47