AJAX - The Complete Reference

(avery) #1

PART II


Chapter 8: User Interface Design for Ajax 399


the resolution of the image is, quite a bit of detail could be provided for the user to zoom to.
The user could also be allowed to pan across the image if it is quite large. We see these types
of interfaces at numerous mapping sites like http://maps.google.com.
This type of behavior isn’t really Ajax-like in the sense of using an XHR. As you might
recall from Chapter 4, we cannot easily deal with image data using XHRs, though we
certainly can use this object to fetch the image URLs to load. We can give an illusion of Ajax
like interaction though, particularly if using a progressive JPEG that gives the user a sense
of progressive sharpening as they click deeper and deeper and load more data.

Remember, our overriding goal is to meet the speed and interface expectations of the
user rather than be a stickler for how intensively an XHR is employed in an application.

The Danger of Incremental Loading


When discussing the use of network calls to fetch more and more data from a large data set,
it seems there is an obvious balance between too much and too little. If too much is fetched
at first or as going along, there might be intolerable wait times, making the application feel
as slow as a traditional application. However, if very little is fetched at a time, latency
problems could be encountered if network conditions change. Any single fetch is quite
small, but if it doesn’t make it in time, the user really notices the glitch.
Is there an art or a science to the too much or too little debate? If it was a science, you
would likely have to keep track of the user’s connection latency and adjust the data size to
suit. If you were looking to take more of an educated guess that fits most users, you could
play with the data size as you build your app and come up with the “magic” number that
makes it right for most. As an experiment, we provide an example to explore various
amounts of data being brought back for an ever-expanding to-do list (http://ajaxref.com/
ch8/listloadexplorer.html) shown in Figure 8-18. In this example, you can generate a large
amount of links to browse in the form of an expandable list. How much you generate and
how you fetch it can be adjusted. Two canned examples show extremes of going to network
too often as well as getting too much data up front.
Free download pdf