Datasheet

As with JavaScript, this book does not teach you how to use PHP and ASP.NET. It’s expected that you
will know either one or the other. Server-side technologies are examined more closely in Chapter 3, but
the current discussion attempts to avoid going into them in too much detail because they provide the
glue for Ajax, rather than the backbone.
With all the pieces of the Ajax puzzle in place, let’s now look more closely at how Ajax changes the tradi-
tional method of web interaction.
The Ajax Application Model
At first, the Web intended to display only HTML documents. This means that the classic web application
has an “enter your data, send the page to the server, and wait for a response” model, intended only for
web pages. Second, there is the problem of synchronous communication. A good example of a real-
world synchronous device is a public telephone booth. You have to call somebody, and that person has
to be available to communicate with you. With many public telephone booths, you cannot get the
receiver to call you back. You can only call the receiver and impart information. After the call you must
leave the booth, as quite often there will be other people waiting to use it. If the receiver hasn’t given
you the information you need, then that is too bad. An example of asynchronous communication would
be with your home phone where you phone someone, and they can’t give you the information you need
right now, so they agree to call you back when they do have the information, whenever that might be.
On the Web, synchronous means that the user requests an HTML page, and the browser sends an HTTP
request to a web server on his or her behalf (Figure 1-6). The server performs the processing, then
returns a response to the browser in the form of an HTML page. The browser displays the HTML page
requested. The browser always initiates the requests, whereas the web server merely responds to such
browser requests. The web server never initiates requests the communication is always one way. The
“request/response” cycle is synchronous, during which the user has to wait.
Figure 1-6: Synchronous model.
Web
Server
Browser
HTTP Request
(http://web site)
HTTP Response
WEB
PAGE
16
Chapter 1: Introducing Ajax
04_106754 ch01.qxp 2/9/07 6:15 PM Page 16