What You Need To Know About Ajax

You hear the word Ajax a lot these days, particularly in technology, so; what are people talking about? A Greek hero from the Odyssey – sure. A bathroom cleanser that gets your sink sparkly – indeed. But today, more often then not, Ajax refers to a specific type of web programming that has taken the internet by storm.

The term Ajax was coined as shorthand for – Asynchronous JavaScript and XML by a man named Jesse James Garrett who founded a technical consultancy called Adaptive Path. He would want me to make it clear that Ajax is not an acronym (so it isn’t spelled AJAX).

What Mr. Garrett described back in 2005 was a stack of technologies (not a single technology) being used at the time by very cutting-edge web sites. This stack of technologies allowed web sites to be turned from a set of static documents connected by hypertext links into something that approximated a true application. This was the intellectual birth (or coming out party anyway) of the Rich Internet Application (RIA).

At the heart of Ajax is a software object built into all browsers called the XMLHttpRequest object. This mouthful is frequently shortened to XHR for those that want to talk about it in fewer syllables. This software object allows JavaScript code, executed in the browser, to go out and request data from a server without reloading a page.

This technology was not new in 2005, but Mr. Garrett put a catchy name to it, and people noticed. Around the same time, a number of web applications such as Gmail emerged and people wondered, “how the heck did they do that?”

Think of a typical web page as one where you have to click a link or submit a form then wait for a new page to be returned to see your result. It’s slow and doesn’t really act the way we expect software to act. Now look at web applications like Flickr, Gmail, or Youtube. You can click in a box and enter some data, and your updates happen without you leaving the page. The magic that’s happening in the background is Ajax (or and XRH call).

With Ajax, the idea is that you get a richer, faster user experience. Properly implemented, a web page can become a rich internet application (RIA). Most extremely popular web sites use Ajax to some degree. Amazon’s rating system, where you click on the number of stars you give a book or CD is one example.

Even though Ajax and XMLHttpRequest both refernce XML, the data that is used does not necessarily have to be formatted as XML. In fact, more and more other data formats, such as JavaScript Object Notation (JSON), are being used. One restriction on XHR is called the single origin policy. This is a security policy, enforced by the browsers, that only allows JavaScript to request data from the server that originally served up a page. There is a technique using JSON that get around this restriction.

Since 2005 a number of toolkits have emerged that have allowed web developers to more easily implement Ajax in their applications. Some of these are Dojo, Prototype, jQuery, GWT, YUI… and many many others.

As a technology stack, Ajax is now quite mature and being used almost everywhere on the web. Ultimately, the most important thing to remember is to create the best posisble user experience.

Posted under JavaScript

Published on 09/06/2010

Tags: , , ,

 

Leave a Comment

Name (required)

Email (required)

Website

Comments

More Blog Post

Previose Post: