Serious Ajax Programming
IN THIS CHAPTER
- Handling multiple XMLHttpRequest requests
- Using two XMLHttpRequest requests
- Using an array of XMLHttpRequest requests
- Using inner functions and multiple XMLHttpRequest requests
- Overcoming browser caching
In Chapter 3 you got your feet wet with Ajax by writing complete Ajax applications. This chapter takes over from there, giving you a working knowledge of the skills you'll need to work through the rest of this book. In other words, you're going to see some serious Ajax here.
This chapter starts by working with multiple XMLHttpRequest objects. For example, if you present the user with two buttons, each of which downloads different data from the server, you can't count on the user to not press both buttons and wait for the results from the server. That's a problem, because Ajax is asynchronous, remember? It doesn't block execution of your code until it gets a result from the server. So if you have only one XMLHttpRequest object, and each time the user clicks a button you connect an anonymous function to its onreadystatechange property, which XMLHttpRequest request are you responding to — the one from the first button click or the second button click? You'll tackle that problem first in this chapter.