If you've been involved in Web development for any amount of time, the latest trend of developing applications with remote scripting capabilities via AJAX (Asynchronous JavaScript + XML) will not be a surprise. After all, it has been available for many years with the drawback being browser inconsistencies. Microsoft always promoted ActiveX as the way to go, but this approach has changed with AJAX's rise in popularity. Let's take a closer look at the AJAX revolution, including Microsoft's involvement and approach.

What is AJAX?

Defining AJAX is not as simple as pointing to a W3C page because it is a collection of technologies. It combines the following:

  • Standards-based presentation layer utilizing XHTML and CSS
  • The DOM (Document Object Model) is used for dynamic display and user interaction
  • Asynchronous data retrieval via XMLHttpRequest
  • XML and XSLT allow data interchange and manipulation
  • JavaScript is used to tie everything together

The big difference between the AJAX approach and traditional Web development is remote scripting. Remote scripting allows client-side JavaScript to request data from a server without refreshing the Web page. This is accomplished via JavaScript and the XMLHttpRequest object. Remote scripting moves some of the processing to the client (browser), which greatly reduces the number of calls to the Web server.

Weekly .NET tips in your inbox
TechRepublic's free .NET newsletter, delivered each Wednesday, contains useful tips and coding examples on topics such as Web services, ASP.NET, ADO.NET, and Visual Studio .NET.
Automatically sign up today!

Microsoft first implemented the XMLHttpRequest object in Internet Explorer 5 for Windows as an ActiveX object. Outlook Web Access was first developed with this ActiveX component. Engineers on the Mozilla project implemented a compatible native version for Mozilla 1.0 (and Netscape 7) with Apple adding support in their Safari 1.2 browser. Similar functionality is covered in a proposed W3C standard. In the meantime, the XMLHttpRequest object has become a de facto standard.

A middle man

A traditional Web application triggers a call to the HTTP server for a user action or request. In turn, the server performs some tasks and returns an HTML page to the requesting client. It is a disconnected user experience, where the user is left waiting much of the time while the server requests finish.

AJAX applications eliminate the start-stop-start-stop nature of Web interactions by introducing an intermediary between the user and the server. The client browser loads the AJAX engine upon the start of a session. The AJAX engine is written in JavaScript and is usually tucked away in a hidden frame. It is responsible for both rendering the user interface and communicating with the server. The AJAX engine allows the user's interaction with the application to happen asynchronously independent of communication with the Web server.

AJAX in action

The AJAX approach is appealing to major companies like Google and Amazon. Google has used the AJAX approach extensively in the development of its Gmail, Google Suggest, and Google Maps Web applications. (Actually, Google has made a huge investment in AJAX in all of its major recently developed or enhanced products.) Likewise, Amazon followed a similar course with its A9 search engine. There are many more examples available every day.

Microsoft's AJAX

Of course, Microsoft is at work to develop a better AJAX. Atlas is the codename for their upcoming AJAX support. It goes well beyond the original concept, including integrated debugging with Visual Studio. In addition, new ASP.NET server controls will be available to easily bind client-side controls to server-side code. The Atlas Client Script Framework will make it easy to interact with pages and such. However, it will not be available in Visual Studio 2005.

Microsoft recently announced that the Atlas Client Script Framework will include the following components (as detailed on the Atlas project site):

  • Extensible core framework adding features to JavaScript such as lifetime management, inheritance, multicast event handlers, and interfaces.
  • Base class library for common features such as rich string manipulation, timers, and running tasks.
  • User interface framework for attaching dynamic behaviors to HTML.
  • A network stack simplifying server connectivity and Web service access.
  • A set of controls for rich user interface development--such as auto-complete textboxes, animation, and drag-and-drop.
  • A browser compatibility layer addressing browser scripting behavior differences.

These announcements are preliminary, so they can easily change before the actual product is released. If you can't wait for Microsoft, the freely available Ajax.NET library for the Microsoft .NET Framework is available now.

Drawbacks to AJAX

The AJAX approach requires users to have JavaScript enabled in their browser. While this should not be a major problem, it is a consideration. Likewise, these applications have to be tested rigorously to deal with the quirks of different browsers and platforms; however, this is already the case with any browser-based application not contained within an Intranet where the target browser can be controlled.

One complaint about the AJAX approach centers on it disabling the proper function of the browser's Back button since the dynamic update of a page is not recognized by the browser as going to a different page. There are many workarounds for this problem with an IFRAME's often utilized approach (Google Maps uses this approach).

One last criticism that I find amusing is people claiming AJAX is just a new term introduced as a marketing vehicle for older technologies. While this may be true, at least the included technologies are mature and tested.

New twist on an old approach

The AJAX approach to Web development is not new, but the broad support by all major browsers does make it more accessible and applicable to the Web development community at large. The technologies utilized in AJAX are mature and stable. It allows you to develop rich applications that require less server roundtrips, so the user spends less time waiting.