ajax - AJAX 可以使用 HTTP 或 HTTPS 以外的协议(protocol)吗?

标签 ajax http https protocols

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

最佳答案

Ajax 表示 XMLHttpRequest .正如您不必将 XML 与 XHR 结合使用一样,您也不必使用 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).

来自W3C XMLHttpRequest spec (强调):

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.

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


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

关于ajax - AJAX 可以使用 HTTP 或 HTTPS 以外的协议(protocol)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6301280/

相关文章:

php - Google recaptcha 与我的 jquery/ajax 函数

php - 使用 xmlhttprequest 将 javascript 变量传递给 PHP

c - 如何在 C 中通过 HTTP 写入图像?

node.js - 如何使用 node.js 加密网页的一部分

amazon-web-services - 在aws中使用golang创建websocket

php - ajax 成功函数未触发

java - 通过http post请求发送键值参数和json消息体

android - 应用程序到 Web API 产生 400 无效的主机名

redirect - 重定向到 https 时 Nginx 不从 root 服务

ios - cordova ios 中的基本身份验证失败