Last Updated:

AJAX helps to increase look for the web

The technologies behind typical Web applications—HTML and HTTP—are simple, but this simplicity comes at a great cost. Because regular HTML pages do not provide constant communication with the server, it is difficult for developers to build interactive, responsive interfaces with the ability to process dynamic data. Java and Flash technologies allow you to embed applets into Web pages, but they change the usual behavior of the browser, and this scares off users. Interoperability with the server is provided by the data-binding controls offered by Microsoft, but many developers are reluctant to use such proprietary extensions.

Fortunately, there are other methods of increasing the level of interactivity of Web applications, invented by developers. These methods are increasingly classified as AJAX: Asynchronous JavaScript and XML. AJAX is not a specific product or technology, but a generic name for a disjointed set of methods often used together. This approach is sometimes referred to simply as DHTML (Dynamic HTML).

The term AJAX, coined by Jess James Garrett of Adaptive Path, a user consulting company, quickly gained popularity as a concise way to describe technologies that enable asynchronous web applications to communicate with a server. AJAX techniques in action can be seen on sites such as Google Maps (www.googlemaps.com).

The most important feature of these and other AJAX applications is represented by the first letter A of this acronym: asynchronous. In AJAX applications, the HTML page that the server forwards to the Web browser contains not only the visible content of the page, but also the active client software module. This module runs in the background, when the page is displayed in a browser window, and interacts with the server asynchronously. With events such as keystrokes or mouse clicks, the program requests additional data from the server, which it can place on the reproduced page after receiving them, without loading it again in its entirety.

This type of interaction is extremely rare on the Web. The usual procedure for loading a Web page consists of several steps. First, the browser sends a request to the server with the URL; in response, the server transmits to the browser the content represented by the HTML page or bytes that make up the image. The browser plays the received text or image, and the server task is completed until the next request. When a new request arrives, the server responds to it, and the browser loads the new page as a whole. The user notices not only the fact of a complete refresh of the page, but also a significant delay caused by the exchange of data between the client and the server.

The advantages of AJAX will be appreciated primarily by those who know from their own experience what Web applications are with improved responses to user actions, while not deprived of the ability to store vast amounts of data and make requests to the server. In addition to the features you already have, such as auto-completion as you type into forms and executing queries without reloading the entire page, it's easy to imagine other scenarios where real-time interaction with the server plays an important role. This includes, for example, spell checking and correction, data validation, and dynamic pricing for complex products. AJAX-based solutions can use on-demand data retrieval techniques combined with predictive caching techniques to perform operations faster. Well-designed AJAX applications do not change the usual browser behavior for the user - for example, the Back button performs its previous function. (When forming a bookmark for a page displayed by an AJAX application, an explicit link is usually required because the Start Page URL does not reflect the status of the entire application.)

AJAX attracts developers by the fact that it does not belong to the number of proprietary and combines well-known technologies. However, preparing an AJAX application can require considerable effort and extensive testing. Of course, a significant part of the client-server interaction operations rests on a JavaScript object called XMLHttpRequest, but implementing AJAX features is much more complex than simply embedding standard HTML form controls into a Web page. In addition, it can be difficult to build, debug, and maintain large JavaScript scripts.

You can develop AJAX applications from scratch, but it will be faster if you take as a basis some simple sample, for example, Ruby on Rails (www.rubyonrails.org) or Echo2 (www.nextapp.com/products/echo2). Then there's "Atlas," an AJAX-like set of extensions for ASP.NET 2.0 that Microsoft unveiled at the Professional Developers Conference in September 2005.