AJAX - The Complete Reference

(avery) #1

PART II


Chapter 6: Networking Considerations 241


Dealing with Multiple Requests


It is quite possible that more than one request may be issued at a time, which certainly
would utilize the true power Ajax provides. However, there are issues that will quickly crop
up when issuing multiple requests as illustrated in the example found at http://ajaxref.
com/ch6/nativequeue.html. In this example, ten asynchronous requests are spawned that
have no timeouts and the first two requests are going to take quite a long time for some
reason. What happens in this scenario is that all the requests appear to be sent but nothing
returns for quite some time, not even the no-delay requests even though they have been
sent. After about five seconds you will see that request 1 comes back and suddenly requests
3 to 10 finish up as well. Request 2 eventually comes back and all the requests are back. You
can see this scenario in Figure 6-6.
Now, if you add the timeout concept from earlier in the chapter to the previous scenario,
you will see all the requests are sent, but the two slow requests seem to jam everything up
and cause all the requests to timeout, as illustrated in Figure 6-7.

FIGURE 6-6 Slow requests stall the rest
Free download pdf