Datasheet
As mentioned, this model works for browsing web pages, but the development of more and more com-
plex web applications means that this model is now breaking down. The first area in which it breaks
down is that of performance. The “enter, send, and wait” approach means there is wasted time. Second,
whenever you refresh a page, you are sending a new request back to the server. This takes up extra
server processing, and it leads to time lost while waiting for a response and higher bandwidth consump-
tion caused by redundant page refreshes. The underlying problem is that there is a complete lack of two-
way, real-time communication capability, and the server has no way in which to initiate updates.
This scenario leads to slow, unreliable, low-productivity and inefficient web applications. You have two
basic problems here: one of having to wait for a response for the server and one of the server not being
able to initiate an update. The Ajax application model seeks to produce higher performance, thereby cre-
ating more efficient web applications by subtly altering the way in which this works.
Ajax introduces the idea of a “partial screen update” to the web application model. In an Ajax applica-
tion, only the user interface elements that contain new information will be updated. The rest of the user
interface should be unchanged. This means that you don’t have to send as much information down the
line, and you’re not left waiting for a response because the previous page is already operational. This
model enables continuous operation of a web page, and it also means that work done on the page does-
n’t have to follow a straight, predictable pattern.
Instead of a synchronous model, you can now have either an asynchronous model or a polling one. In an
Ajax application, the server can leave a notification today when it’s ready, and the client will pick it up
when it wants to. Or, the client can poll the server at regular intervals to see if the server’s ready, but it
can continue with other operations in the meantime, as shown in Figure 1-7.
Figure 1-7: Model in Ajax application.
As a result, the user can continue to use the application while the client requests information from the
server in the background. When the new data finally does turn up, only the related parts of the user
interface need to be updated.
Why Should I Use Ajax?
We’ve looked at the model, but let’s now spell out in real terms the advantages of using Ajax to create
your applications. This is my equivalent of the second-hand car dealer’s hard-sell.
Partial Page Updating
You don’t have to update the data on an entire page. You can update only the portions of the page that
require it. This should mean no full page refreshes, less data to be transferred, and an improved flow for
the user experience. You don’t have to stutter from page to page.
Browser
Http Request
Http Response
Ajax
Web
Server
17
Chapter 1: Introducing Ajax
04_106754 ch01.qxp 2/9/07 6:15 PM Page 17