如何在链接或表单中指定DELETE方法? [英] How to specify DELETE method in a link or form?

查看:187
本文介绍了如何在链接或表单中指定DELETE方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rfc2616列出了除GET和POST之外的许多方法,例如DELETE,PUT等。但是html格式的方法字段似乎只允许指定GET或POST。

Rfc2616 lists many methods besides GET and POST, like, say, DELETE, PUT etc. Method field in html forms, though, seems to be allowed to specify only GET or POST.

是否可以在html页面中创建使用非GET或POST请求方法的链接或表单?

Is it possible to create a link or form in a html page that uses a request method that is not GET or POST?

推荐答案

试图为前端使用Angular的rails应用程序解决这个问题;这些似乎适用于该环境:

Was trying to figure this out for a rails app that was using Angular on the front end; these seems to work for that environment:

<a data-confirm="Are you sure?" data-method="delete" href="/link-to-resource" rel="nofollow">Delete</a>

编辑:只是为了让每个人都站起来,我想你仍然需要为此提供jQuery工作。我删除了jQuery,它停止了工作;我把它放回去了,它开始工作了。

Just to give everyone a heads up, I think you still need to have jQuery for this to work. I removed jQuery and it stopped working; I put it back and it started working.

这篇关于如何在链接或表单中指定DELETE方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆