Ajax

We will cover this topic if there is time. It is presented in Chapter 17.

At its heart, Ajax is about using Javascript to make HTTP requests dynamically, and using the results to update the page. The usual pattern is that the browser makes an HTTP request to the server. The returned page may contain Javascript, which can then interact with the user. But if more information is needed from the server, a new page must be loaded.

There are ways for Javascript to instruct the browser to load a new page, or the Javascript can insert links into the page which the user can click on to make a new page. These links can be customized to respond to user input. But that always produces the overhead of fetching and parsing an entire page. With Ajax, the Javascript program itself performs the HTTP request, receives the response, and uses it to update the current page. If done well, this can be much faster than the process of fetching a new page, and make the whole process much more responsive.

Google Maps was one of the first widely-used Ajax applications. It uses Ajax requests to fill in portions of the map when it slides. This can't be done smoothly under the older model.