AJAX - The Complete Reference

(avery) #1

PART II


Chapter 8: User Interface Design for Ajax 397


or even more items would be fetched behind the scenes with Ajax so that the data appears
to be available instantly as they page.

We might even progressively load the items until the whole data has been fetched just in
case. That might be a bit wasteful though unless we expect people to use all the
downloaded content.
Another way to present the same idea of progressive loading outside pagination is
using continuous scrolling. We demonstrated this pattern in Chapter 6 when discussing
Ajax prefetching techniques. However, as a refresher, imagine a long page that initially only
has a portion of it loaded and then as the user scrolls, more content would be loaded to
increase the length of the document. As long as the content arrives before the user, they’d be
none the wiser, but be careful—an aggressive user spinning their mouse wheel can certainly
cause some real loading trouble with this pattern.
You should play with the example code online (http://ajaxref.com/ch8/longscroll.html)
to see if you like this pattern. If it is something you want to implement, make sure to note
the large function checkScroll(), which addresses the numerous little nuances for
calculating inner window and document size across browsers. Figure 8-17 shows this last
example (http://ajaxref.com/ch8/longscroll.html) in action with a network trace revealing
the fetches during scroll.
Free download pdf