AJAX - The Complete Reference

(avery) #1

PART II


Chapter 6: Networking Considerations 253


AjaxTCR.comm._handleCallbacks(AjaxTCR.comm.queue._responseQueue
.queue[AjaxTCR.comm.queue._responseQueue.currentIndex]);

AjaxTCR.comm.queue.responseQueue.currentIndex++;
}
}

NNOT EOTE It is possible to block everything until all responses come back to enforce order. We opt not to
do that as it is quite slow but instead choose to buffer responses and fetch more, eventually
invoking callbacks once the dependent requests have finally returned. It is of course easy enough
to create this concept via the request queue that is implemented in the library.

With the response queue in place, you can see in Figure 6-13 that the multiple requests
now make sense no matter how many times you run them or how many requests are sent
concurrently.
The need for sequencing will depend much on the design of the application. If requests
do not depend on each other, it really won’t matter much what order they appear in.
However, in the case where there is a dependency, much trouble can ensue. For example,
imagine you are passing XML around as well as XSLT to transform the data to a look. You
might make the requests in the proper order, but the luck of the network will result in the

FIGURE 6-13 Response queuing really makes sense
Free download pdf