Chapter 2. The Nuts and Bolts of Ajax

Ajax is simple and could be described as an 11-line piece of code. So, doing some mental math, describing Ajax and the XMLHttpRequest type[9] should take no more than four or five pages. Yet this chapter is more than four or five pages—in fact, quite a bit more. The reason is that knowing how to use the XMLHttpRequest type does not equate to making the best use of XMLHttpRequest.

The first purpose of this chapter is to introduce and explain a simple Ajax example. The second purpose is to explain a meaningful development strategy using the XMLHttpRequest type.

Ajax for the Impatient

The Ajax example illustrated in this chapter is an HTML page that has a single button. Clicking the single button makes an HTTP request ...

Get Ajax Patterns and Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.