I wonder if AJAX can use protocols other than HTTP or HTTPS.
-
What would be such other protocols? – c-smile Jun 10 '11 at 02:13
-
5FWIW, IE's native XHR object only supports HTTP and HTTPS, although the older ActiveX version can also use FILE://. – EricLaw Jun 10 '11 at 03:36
2 Answers
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 (includingfile
andftp
).
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...)
-
4“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).” — other than that, they did a great job picking the name :) – Paul D. Waite Jul 19 '11 at 07:53
-
Although supposedly supported, there not one working example of xmlhttprequest to an FTP resource to be found anywhere. – frequent Feb 28 '13 at 19:37
-
@frequent have you ever seen non-working examples anywhere? I haven't _ever_ seen even an attempt at using this. FTP is not frequently used for web applications these days, and it's especially useful, since ajax is most useful/interesting for dynamic resources. – Matt Ball Feb 28 '13 at 19:43
-
1@MattBall: My question ([here](http://stackoverflow.com/questions/14839838/what-is-the-syntax-to-do-a-cross-domain-xmlhttprequest-to-an-ftp-server)) has the best link I found. I'm working on a multi-storage javascript plugin. Can do webDav, xwiki, s3... no FTP... pity – frequent Feb 28 '13 at 20:09
XMLHttpRequest (XHR) is an API available to web browser scripting languages such as JavaScript. It is used to send HTTP or HTTPS requests to a web server and load the server response data back into the script.
from wikipedia

- 1
- 1