Datasheet

FIGURE 1.12
Browsing through Amazon.com
Get the answer with Ajax autocomplete
Ajax autocomplete applications are a lot like live searches. With live searches, you can enter a par-
tial term in a text field. With autocomplete, however, there’s no search involved; autocomplete sim-
ply offers suggestions to complete the term you’re typing (if you do any cell phone text messaging,
you’re probably familiar with the idea many cell phones offer suggestions to complete a term as
you’re typing it).
You can see an autocomplete example at
www.papermountain.org/demos/live/, which is
shown in Figure 1.13.
Just type a partial English word in the text field as shown in Figure 1.13, and the application sends
your partial word to the server, which finds matches to that word and sends back autocomplete
suggestions. Those suggestions appear, as you see in Figure 1.13, and you can select among them.
When you do, the term you select replaces the partial term you’ve already typed.
You can find another autocomplete example available for download from SWATO, an Ajax toolkit,
at
https://swato.dev.java.net/. You can see this example at work in Figure 1.14.
This example matches the names of countries, as shown in Figure 1.14. All you need to do is to
type, say, “A”, to be shown a set of possible completions, including Algeria, Austria, Australia, and
so on.
13
Essential Ajax
1
06_102633 ch01.qxp 2/23/07 9:44 PM Page 13