IT Pro is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more

AJAX - web applications the easy way

IT Pro Guide: It's not a cleaning product, or a hero from classical civilisation... so what is it? Marcus Austin delves into the detail behind AJAX, one of the Web's latest buzzwords

You will all by now have used web applications such as Google's Gmail email service or their Toolbar service. If not then perhaps you should, because you'll be amazed by just how quickly they work.

If you compare Gmail to another webmail-based system the first thing you'll notice is the screen refresh time. With webmail you're constantly waiting for a new page to be drawn from scratch as you move between emails. Gmail, however, seems to refresh the screen in an instant. The secret behind this and other similar web applications is a combination of software applications and services that are collectively known as Asynchronous JavaScript And XML, or more commonly by the acronym AJAX, and they're revolutionising the way websites interact with users.

The main reason why Ajax applications are so fast at what they do is because they're client-side applications that run on users' PCs. Redraws and any graphical manipulation are all taken care of by the client's processor rather than the web servers at the other end, which increases the speed of response, reduces the server's processor overhead and increases the interactivity between websites and users.

It's a great choice for Web-based chat programs, where many users can chat together at the same time, grabbing lists of data, as in Google's Suggest beta (http://www.google.com/webhp?complete=1), for enabling interactivity in pop-ups, dragging and dropping, or modifying web pages on the fly.

How does it do that?

AJAX works by exchanging small amounts of data with the server behind the scenes, so that the entire Web pages do not have to be reloaded each time the user makes a change. To the user it looks and feels much more like using a desktop application than a traditional web application.

In fact it's not just one technology achieving this effect it's actually made up of several components. AJAX uses HTML and Cascading Style Sheets (CSS) for the application's look and feel, the data is stored and fetched in XML format, the data fetches use the XMLHttpRequest object, and it uses JavaScript as the glue between all of the different layers.

Compatibility

As with DHTML applications, AJAX applications have to be tested rigorously to deal with the quirks of different browsers and platforms. A number of programming libraries have become available as AJAX has matured that can help ease this task. Likewise, techniques have been developed to assist in designing applications which degrade gracefully and offer alternative functionality for users without JavaScript enabled.

While no browser plug-in is required for AJAX, users need to have JavaScript enabled in their browsers. This applies to all browsers that support AJAX except for Microsoft Internet Explorer 6 and below which also need ActiveX to be enabled. However Microsoft has announced that Internet Explorer 7 should be able to implement AJAX applications without ActiveX.

Another common complaint about AJAX applications is that they can break back button functionality in browsers. Google Maps demonstrates, however, that with careful coding, such browser functionality need not be compromised.

Fallback

Because AJAX requires so many features to be enabled before it will work and it's limited to just a few browsers, anyone working on AJAX web applications should look at providing fallback options for those on other platforms or browsers - visually impaired users, for instance. It's also essential that you don't rely on it as the only way you interact with your users.

Be aware, however, that some fallback options can put extra strain on your server and can be time consuming to build, so developers need to make the decision early on as to how important those non-AJAX users are. Google has made the decision for Gmail not to fall back, for instance, and it gets around this by keeping the service in a constant state of beta, playing a waiting game with users' browser capabilities.

Featured Resources

Accelerating AI modernisation with data infrastructure

Generate business value from your AI initiatives

Free Download

Recommendations for managing AI risks

Integrate your external AI tool findings into your broader security programs

Free Download

Modernise your legacy databases in the cloud

An introduction to cloud databases

Free Download

Powering through to innovation

IT agility drive digital transformation

Free Download

Most Popular

Salaries for the least popular programming languages surge as much as 44%
Development

Salaries for the least popular programming languages surge as much as 44%

23 Jun 2022
Attracting and retaining talent through training
Sponsored

Attracting and retaining talent through training

13 Jun 2022
The top programming languages you need to learn for 2022
Careers & training

The top programming languages you need to learn for 2022

23 Jun 2022