AJAX - The Complete Reference

(avery) #1

394 Part II: Developing an Ajax Library^


Before wrapping up this section, we should note that there is the outside possibility that
between the time that a user has picked an open account and the time they submit it for
processing, it has been taken. We could certainly put a “hold” on accounts that have been
verified for a short period of time on the server side, or we could avoid such code if it
becomes unwieldy to do so. Such application architecture types of questions certainly are
discussed in the next chapter.

Previewing


As we have seen, it is very useful to fetch data with Ajax to improve searching and form
fill out, but it is even possible to use the technology to fetch a preview of content if not the
content itself. Consider being presented a list of interesting news stories. It might be useful
to fetch a preview of the story, say a snippet or summary upon mouseover to give a taste of
what’s ahead. With previewing, the user can decide if they want to commit to downloading
the full story or not based upon what they see. The idea is visually demonstrated here:

The code for this example is quite simple: it just invokes an XHR upon mouseover of a
link and fetches a snippet of the content it would go to. The returned content is then used to
set the title attribute of the <a> tag being hovered over. This simple tooltip example can be
found online at http://ajaxref.com/ch8/tooltip.html.
If you find the delayed timing or visual presentation of standard XHTML title attribute-
based tooltips not to your liking, you certainly can create your own custom tooltip using
Free download pdf