Asynchronous JavaScript and XML

From Hill2dot0
(Redirected from AJAX)
Jump to: navigation, search

Asynchronous JavaScript and XML (AJAX) is a collection of tools and techniques for Web application development. The term was coined by Jesse James Garrett of the consulting firm Adaptive Path in a February 2005 article. AJAX is essentially a way to create highly interactive Web pages. A remote scripting approach, AJAX makes it possible for small portions of the page to be altered or reloaded without reloading the entire Web page. This is a critical capability as applications are increasingly integrated and extended to handhelds that might be on lower speed transmission links; here, reloading entire pages can significantly impact performance.

AJAX is not a single technology. It combines several elements: a formatting language, a remote scripting language, a standard information representation, and a protocol for exchanging small pieces of information between the client and the server.

The formatting language is about structuring the Web page. Standard HyperText Markup Language (HTML) can be used, or a stricter version of the language called Extensible HTML (XHTML) can be employed. The latter is based on XML. Although several different remote scripting languages could be used, the default (and most commonly used) language is JavaScript Remote Scripting (JSRS). The information representation standard is the Extensible Markup Language (XML), and the protocol for exchanging information with the server is XMLHttpRequest. XMLHttpRequest is actually an application programming interface (API). As its name implies, it is a protocol for retrieving XML data from a server using the HyperText Transfer Protocol (HTTP). Although the intent of the protocol was to fetch and manipulate XML formatted data, XMLHttpRequest can also be used for other data formats.

Today, AJAX development tool-kits are available from dozens of sources, including such big names as Google and Microsoft. A variety of AJAX applications can be found scattered around the Internet. Two of the more interesting ones include ProtoPage and AJAXwrite. ProtoPage is a customized home page application similar to Google IG or My Yahoo!. Compared to both of those, however, ProtoPage demonstrates the incredible flexibility and responsiveness of the approach. AJAXwrite is a Web-based application that can read and write many kinds of standard documents, including MS Word. That example, however, requires a FireFox browser (version 1.5 or better). Other examples of AJAX or AJAX-like programming include Google Earth, Amazon’s A9.com search engine, and Flickr.

Benefits and Limitations of AJAX

AJAX has several important benefits. First, it produces a highly interactive client environment that is rapidly customizable; it can be designed so that the user can customize it as well. This makes applications incredibly flexible. Second, because it is based on industry standards supported in most browser and server platforms, AJAX is highly portable. AJAX applications, for the most part, can run in most modern browsers. Finally, AJAX can go a long way to optimizing network and server loads. This is largely due to the exchange of small packets of information rather than entire Web pages when changes to a Web page are made.

AJAX has some limitations as well. First, the user can be left fairly confused if the AJAX application is not carefully crafted. Altering small elements of a page can break the function of the back button on the browser and can make bookmarking problematic. There are workarounds for both of these, but developers need to be aware of them and implement them carefully.

AJAX also supports a capability known as smart preloading. If a page contains multiple links, an AJAX application can selectively preload all or some of these links so that, if the user clicks on the link, the requested page has already been locally cached and loads quickly. Heavy use of this feature can produce peculiar latency effects that leave the user wondering if the application is “hung.” It can also completely defeat the network and server optimization goals because it creates a possibility that much information that is not desired or ever accessed by the user is actually pulled off the server and transported across the network. Network load and server load are being traded for user satisfaction and increased response time.

Because AJAX is JavaScript-based, the browser must have JavaScript enabled. In some contexts, this feature might not be enabled, which would require an IT policy and configuration change. And rigorous testing must be conducted to verify execution in all possible browser environments.

Finally, the ease with which legacy applications can be reworked using AJAX techniques will vary widely. This somewhat depends on how tightly coupled the application logic is to the lower protocol layers. The more entwined these are, the more difficult it will be to rework the application using AJAX principles.

PodSnacks

<mp3>http://podcast.hill-vt.com/podsnacks/2008q1/ajax.mp3%7Cdownload</mp3> | Asynchronous JavaScript and XML (AJAX)