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.

Advertisement
Advertisement - Article continues below
Advertisement - Article continues below

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.

Advertisement - Article continues below

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

The IT Pro guide to Windows 10 migration

Everything you need to know for a successful transition

Download now

Managing security risk and compliance in a challenging landscape

How key technology partners grow with your organisation

Download now

Software-defined storage for dummies

Control storage costs, eliminate storage bottlenecks and solve storage management challenges

Download now

6 best practices for escaping ransomware

A complete guide to tackling ransomware attacks

Download now
Advertisement

Most Popular

Visit/security/identity-and-access-management-iam/354289/44-million-microsoft-customers-found-using
identity and access management (IAM)

44 million Microsoft customers found using compromised passwords

6 Dec 2019
Visit/cloud/microsoft-azure/354230/microsoft-not-amazon-is-going-to-win-the-cloud-wars
Microsoft Azure

Microsoft, not Amazon, is going to win the cloud wars

30 Nov 2019
Visit/hardware/354237/five-signs-that-its-time-to-retire-it-kit
Sponsored

Five signs that it’s time to retire IT kit

29 Nov 2019
Visit/business/business-strategy/354195/where-modernisation-and-sustainability-meet-a-tale-of-two
Sponsored

Where modernisation and sustainability meet: A tale of two benefits

25 Nov 2019