Datasheet
The Real Ajax
Despite the frequently asked questions attached to the end of Garrett’s essay, some confusion still exists
as to what Ajax really is. Put simply, Ajax is nothing more than an approach to web interaction. This
approach involves transmitting only a small amount of information to and from the server in order to
give the user the most responsive experience possible.
Instead of the traditional web application model where the browser itself is responsible for initiating
requests to, and processing requests from, the web server, the Ajax model provides an intermediate layer —
what Garrett calls an Ajax engine—to handle this communication. An Ajax engine is really just a JavaScript
object or function that is called whenever information needs to be requested from the server. Instead of the
traditional model of providing a link to another resource (such as another web page), each link makes a call
to the Ajax engine, which schedules and executes the request. The request is done asynchronously, mean-
ing that code execution doesn’t wait for a response before continuing.
The server — which traditionally would serve up HTML, images, CSS, or JavaScript — is configured to
return data that the Ajax engine can use. This data can be plain text, XML, or any other data format that
you may need. The only requirement is that the Ajax engine can understand and interpret the data
When the Ajax engine receives the server response, it goes into action, often parsing the data and making
several changes to the user interface based on the information it was provided. Because this process
involves transferring less information than the traditional web application model, user interface updates
are faster, and the user is able to do his or her work more quickly. Figure 1-1 is an adaptation of the figure
in Garrett’s article, displaying the difference between the traditional and Ajax web application models.
Figure 1-1
Web Server
Data
Query/Data
Request
Database
HTML, Images,
CSS, JavaScript
Web Browser
Traditional Web Application Model
HTTP
Request
Web Server
Data
Query/Data
Request
Database
HTML, CSS
JavaScript
Call
Data
Web Browser
Ajax Web Application Model
HTTP
Request
User
Interface
Ajax
Engine
5
What Is Ajax?
04_109496 ch01.qxd 2/5/07 6:47 PM Page 5