http - PUT、DELETE、HEAD 等方法在大多数 Web 浏览器中都可用吗?

标签 http cross-browser browser ajax

我在这里看到了几个问题,例如 How to debug RESTful services ,其中提到:

Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.

我还从其他一些来源听说浏览器仅支持 GET 和 POST,例如:

但是,Firefox 中的一些快速测试表明发送 PUTDELETE 请求按预期工作 - XMLHttpRequest 成功完成,并且该请求以正确的方法显示在服务器日志中。我是否缺少某些方面,例如跨浏览器兼容性或不明显的限制?

最佳答案

没有。 HTML 5 spec提及:

The method and formmethod content attributes are enumerated attributes with the following keywords and states:

The keyword get, mapping to the state GET, indicating the HTTP GET method. The GET method should only request and retrieve data and should have no other effect.

The keyword post, mapping to the state POST, indicating the HTTP POST method. The POST method requests that the server accept the submitted form's data to be processed, which may result in an item being added to a database, the creation of a new web page resource, the updating of the existing page, or all of the mentioned outcomes.

The keyword dialog, mapping to the state dialog, indicating that submitting the form is intended to close the dialog box in which the form finds itself, if any, and otherwise not submit.

The invalid value default for these attributes is the GET state

即HTML 表单仅支持 GETPOST 作为 HTTP 请求方法。解决此问题的方法是使用隐藏的表单字段通过 POST 隧道其他方法,该字段由服务器读取并相应地分派(dispatch)请求。

但是,GETPOSTPUTDELETE 支持 XMLHttpRequest(即 AJAX 调用)在所有主要 Web 浏览器(IE、Firefox、Safari、Chrome、Opera)中的实现。

关于http - PUT、DELETE、HEAD 等方法在大多数 Web 浏览器中都可用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11035927/

相关文章:

javascript - jQuery slider 闪烁问题if slide

JQuery.ready 来不及了 : How do I apply CSS Values with JQuery before Rendering?

flash - Adobe Flash 浏览器是独立的吗?

JavaScript 浏览器检测有效,但之后显示 'undefined'

html - onscroll - 浏览器渲染优化 - layers hack - will-change

html - 如何使用HTML5或WEBRTC在浏览器中发送UDP包?

php - PHP 中的异步 HTTP 请求

javascript - 因此,AngularJS : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' 不允许访问

wordpress - 只有主页适用于 Wordpress https

java - 如何为 java HttpURLConnection 流量启用线路日志记录?