Javascript HTML 表单 PUT 方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7257481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML form PUT method
提问by Dagang
Because the server side only accepts PUT method, I used method='PUT'in the HTML form. But the browser didn't use method PUT as expected, it's GET. When I set method='POST'it's POST.
I don't know why method='PUT'doesn't work. I have tested on Chrome and Firefox.
因为服务器端只接受 PUT 方法,所以我method='PUT'在 HTML 表单中使用。但是浏览器并没有像预期的那样使用 PUT 方法,它是GET. 当我设置method='POST'它时POST。
我不知道为什么method='PUT'不起作用。我已经在 Chrome 和 Firefox 上进行了测试。
回答by cypher
Browsers only support POSTand GET, if you need PUT, you have to send the form via post/get and then do the proper PUTrequest on server-side.
浏览器仅支持POST并且GET,如果需要PUT,您必须通过 post/get 发送表单,然后PUT在服务器端执行正确的请求。
EDITalthough, most implementations of XMLHttpRequest support PUTand DELETE.
编辑虽然,XMLHttpRequest 的大多数实现支持PUT和DELETE.
回答by bogdancep
PUTis not recognized and is assimilated to GET.
PUT不被承认并被同化GET。
Most frameworks use a hidden input to obtain PUTor DELETE:
大多数框架使用隐藏输入来获取PUT或DELETE:
<input type="hidden" name="_method" value="PUT">

