Linking to a page with a specific HTTP Method (DEL

2019-04-24 14:06发布

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.

标签: html http
2条回答
老娘就宠你
2楼-- · 2019-04-24 14:50

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.

查看更多
够拽才男人
3楼-- · 2019-04-24 14:54

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

查看更多
登录 后发表回答