November 2011
Intermediate to advanced
320 pages
10h 18m
English
The XMLHttpRequest API, mentioned in this book on several prior occasions, gives JavaScript programs the ability to issue almost unconstrained HTTP requests to the server from which the host document originated, and read back response headers and the document body. The ability to do so would not be particularly significant were it not for the fact that the mechanism leverages the existing browser HTTP stack and its amenities, including ambient credentials, caching mechanisms, keep-alive sessions, and so on.
A simple and fairly self-explanatory use of a synchronous XMLHttpRequest could be as follows:
var x = new XMLHttpRequest(); x.open("POST", "/some_script.cgi", false); x.setRequestHeader("X-Random-Header", ...Read now
Unlock full access