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

查看:14
本文介绍了如何在链接或表单中指定 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.

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

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天全站免登陆