Chapter 18. Scripted HTTP
The Hypertext Transfer Protocol (HTTP) specifies how web browsers get documents from and post form contents to web servers, and how web servers respond to those requests and posts. Web browsers obviously handle a lot of HTTP. Usually HTTP is not under the control of scripts and instead occurs when the user clicks on a link, submits a form, or types a URL.
It is possible for JavaScript code to script
HTTP, however. HTTP requests are initiated when a script sets the
location
property of a window object
or calls the submit()
method of a
form object. In both cases, the browser loads a new page. This kind of
trivial HTTP scripting can be useful in a multiframed web page but is
not the topic we’ll cover here. Instead, this chapter explains how
scripts can communicate with a web server without causing the web
browser to reload the content of any window or frame.
The term Ajax describes an architecture for web applications that prominently features scripted HTTP.[43] The key feature of an Ajax application is that it uses scripted HTTP to initiate data exchange with a web server without causing pages to reload. The ability to avoid page reloads (which were the norm in the early days of the Web) results in responsive web applications that feel more like traditional desktop applications. A web application might use Ajax technologies to log user interaction data to the server or to improve its start-up time by displaying only a simple page at first and then downloading ...
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.