AJAX可以使用HTTP或HTTPS以外的协议吗?(Can AJAX use protocols other than HTTP or HTTPS?)

编程入门 行业动态 更新时间:2024-10-15 04:27:03
AJAX可以使用HTTP或HTTPS以外的协议吗?(Can AJAX use protocols other than HTTP or HTTPS?)

我想知道AJAX是否可以使用HTTP或HTTPS以外的协议。

I wonder if AJAX can use protocols other than HTTP or HTTPS.

最满意答案

Ajax表示XMLHttpRequest 。 就像您不必在XHR中使用XML一样,您也不必使用HTTP。

尽管它的名称, XMLHttpRequest可用于检索任何类型的数据,而不仅仅是XML,它支持HTTP以外的协议(包括file和ftp )。

从W3C XMLHttpRequest规范 (重点添加):

XMLHttpRequest对象实现脚本引擎公开的接口,该脚本引擎允许脚本执行HTTP客户端功能,例如提交表单数据或从服务器加载数据。 它是ECMAScript HTTP API。

对象的名称是XMLHttpRequest,用于与Web兼容,但此名称的每个组件都可能具有误导性。 首先,该对象支持任何基于文本的格式,包括XML。 其次,它可以用于通过HTTP和HTTPS发出请求( 除HTTP和HTTPS之外,某些实现还支持协议,但此规范未涵盖该功能 )。 最后,它支持广义上的“请求”,因为它与HTTP有关; 即涉及HTTP请求或定义的HTTP方法的响应的所有活动。

HTTP和HTTPS之外的可用协议是非标准化的,因此它们取决于您正在使用的特定环境1 。 也就是说,所有兼容的XHR实现必须支持HTTP和HTTPS,但不需要支持任何其他特定协议。 这意味着您可能会发现Internet Explorer支持


1例如,哪个版本的浏览器(Safari vs Firefox vs Chrome vs IE vs Opera vs ...),或者哪个服务器端实现(V8 vs Rhino vs ...)

Ajax means XMLHttpRequest. Just as you don't have to use XML with XHR, you also don't have to use HTTP.

Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including file and ftp).

From the W3C XMLHttpRequest spec (emphasis added):

The XMLHttpRequest object implements an interface exposed by a scripting engine that allows scripts to perform HTTP client functionality, such as submitting form data or loading data from a server. It is the ECMAScript HTTP API.

The name of the object is XMLHttpRequest for compatibility with the Web, though each component of this name is potentially misleading. First, the object supports any text based format, including XML. Second, it can be used to make requests over both HTTP and HTTPS (some implementations support protocols in addition to HTTP and HTTPS, but that functionality is not covered by this specification). Finally, it supports "requests" in a broad sense of the term as it pertains to HTTP; namely all activity involved with HTTP requests or responses for the defined HTTP methods.

The available protocols beyond HTTP and HTTPS are non-standardized, so they depend on the specific environment1 you're using. That is, all compliant XHR implementations must support HTTP and HTTPS, but are not required to support any other specific protocols. That means that you might find that Internet Explorer supports


1Such as, which version of which browser (Safari vs Firefox vs Chrome vs IE vs Opera vs...), or which server-side implementation (V8 vs Rhino vs...)

更多推荐

本文发布于:2023-08-04 20:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1422639.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   协议   AJAX   HTTP   protocols

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!