Ajax is the shorthand notation for Asynchronous JavaScript
and XML. It is a web development technique that is used for developing
interactive web applications. Ajax develops interactive web application by
sending a small amount of data to the server behind the scenes. The advantage
of this is that the entire page is not reloaded every time when the user makes
some changes in the input. It may seem that Ajax is some new technology. But
that is not true. It is a new way of combining old technologies and
representing them in a new way.
·
XHTML and CSS - for presentation
·
Document Object Model (DOM) - for dynamic display and interaction
·
XML and XSLT - for data interchange and manipulation
·
XMLHttpRequest - for asynchronous data retrieval
·
Java Script - for binding everything together
Before going deep into Ajax, let us discuss some basics of
web applications. When a person sits down to develop an application, he has two
choices before him.
·
Desktop application
·
Web application
Desktop applications normally come on a CD or are sometimes downloaded
from some web site and are installed completely on the computer. Desktop
application may use Internet sometimes to download some updates, but the code
which is responsible for running those applications reside on the desktop only.
On the other hand, Web applications run on a Web server which is present
somewhere else and a person accesses those applications with the help of his
browser.
Desktop applications are pretty fast since they do not
require any Internet connection to run and they have great user interfaces.
They are also incredibly dynamic. A person can pull up menus and sub-menus and
can do many more things without waiting for anything. And this feature is
almost opposite to what happens in a web application. No doubt that the
services provided by Web applications can never be provided by any desktop
application, but it is also true that the user has to wait for everything in a
Web application. Since Web applications use an Internet connection they are
normally slower that desktop applications. A user has to wait to get a response
back from the server, for the web page to get refreshed, etc.
Now coming down to our topic, normally what happens in most
of the classical web application is that any user request sends a HTTP request
to a web server. The server does some processing to give back the response and
then returns an HTML page to the user. But every time the user submits the page
to the server, the server responds with a totally new page which makes the
application run slower and is less user-friendly. An Ajax application
eliminates this disadvantage by incorporating a middle layer between the user
and the server. That intermediate layer is the Ajax engine.
Actually, what happens here is that instead of loading a web
page, at the start of the session the browser loads the Ajax engine. The Ajax engine is written in JavaScript and is usually placed in a hidden frame. This engine
is responsible for communicating with the server and the user; i.e. it acts as
the link between the server and user machine. The Ajax engine allows
asynchronous interaction of the user with the application, independent of
communication with the server. So here, the user does not have to keep waiting
for the response from the server. In Ajax every user action that would create
any HTTP request takes the form of a JavaScript call to the Ajax engine. Any
user request that can be fulfilled by the engine is done by the engine itself
without bothering the server. But any user request which requires the server
interference, the engine makes those requests asynchronously, usually using
XML, without stopping the user interaction with the application.