The XMLHttpRequest API
When you click a link, submit a form, or in some other way encourage your browser to go to a new page, it will make an HTTP request and, if successful, show the newly loaded document. In typical situations, this is just what you want—it is how the Web traditionally works. Sometimes, however, a JavaScript program wants to communicate with the server without reloading the page.
To be able to do something like that, the program must make the HTTP request itself. Contemporary browsers provide an interface for doing this. As with opening new windows, this interface is subject to some restrictions—to prevent a script from doing anything scary, it is allowed to make HTTP requests only to the domain that the current page came from, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access