As another example, take a look at Figure 5-2. Notice the star where you can highlight
a particularly interesting item. Traditionally, clicking it would require the entire page to be
reloaded (all 16KB of it, not including JavaScript, Cascading Style Sheets [CSS], and images).
With Ajax, the user never leaves the spot, and the interaction sends only a few bytes back
and forth.
99
C H A P T E R 5
Figure 5-1. Google Docs automatically saves changes every minute to prevent losing any
precious changes.
Figure 5-2. The star enables you to target this item as interesting without having to refresh
the page.
Deconstructing the Ajax Process
At the core of Ajax is the XMLHttpRequest object (which is often referred to as XHR). Microsoft
originally developed an ActiveX object to be used for Outlook Web Access way back in 2000.
However, without cross-browser support, the functionality remained mostly in obscurity.
When Mozilla implemented a native version of the object in its browser, things really began
to take hold. Finally, with Safari and Opera implementing it, it took off. Now there are entire
conferences and consortia based on this lovely word.
While Ajax described a very specific set of interactions, its meaning has expanded somewhat
to include a broader concept: any communication to the server via JavaScript using the
XMLHttpRequest object. The data returned might be XML, but it could also be HTML, JSON,
CSV, or whatever text format your heart desires.
Pages:
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165