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 POST
and GET
, if you need PUT
, you have to send the form via post/get and then do the proper PUT
request on server-side.
浏览器仅支持POST
并且GET
,如果需要PUT
,您必须通过 post/get 发送表单,然后PUT
在服务器端执行正确的请求。
EDITalthough, most implementations of XMLHttpRequest support PUT
and DELETE
.
编辑虽然,XMLHttpRequest 的大多数实现支持PUT
和DELETE
.
回答by bogdancep
PUT
is not recognized and is assimilated to GET
.
PUT
不被承认并被同化GET
。
Most frameworks use a hidden input to obtain PUT
or DELETE
:
大多数框架使用隐藏输入来获取PUT
或DELETE
:
<input type="hidden" name="_method" value="PUT">