Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to a page with a specific HTTP Method (DELETE)

Tags:

html

http

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.

like image 445
Carlos Precioso Avatar asked Apr 28 '11 19:04

Carlos Precioso


2 Answers

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.

like image 98
Quentin Avatar answered Oct 26 '22 23:10

Quentin


You can use a javascript plugin like RestfulizerJs for converting your links to pseudo forms.

like image 44
Ifnot Avatar answered Oct 26 '22 23:10

Ifnot