MarkKawakami.com

“A casual relationship with reality”

Ajax: The web's Next Big Thing

I'm about to get technical on your ass. If you found my political posts boring, you ain't seen nothing yet.

Ajax refers to "Asynchronous Javascript + XML", which is an evolving new way for dynamic web pages to process information and provide a richer and less intrusive experience to users. The name might be too-clever, but the technology isn't.

Now, I just about never refer to things as "the next big thing" because for the most part, most things aren't, they're just hype and moments away from fizzling out. That's what I thought about "Push Technology", VRML, social networking sites, B2B, etc., and I've usually been right.

Of course, I've also been pretty wrong too. Peer-to-Peer filesharing and, ironically, blogging are both things that I dismissively said "yeah, right" to and look at it now. At any rate, when I say "the next big thing", I'm not kidding.

But none of that tells you what Ajax is. Simply put, it's a way for a web page to use Javascript to send and receive complex information without users leaving the page that they're on. This might not sound like a big or impressive innovation, but really it is. Up until very recently, the only way for a web browser to communicate required loading a new page. For instance, you type something into a search box, click a button, and a new web page comes back with your search results. Then you click on a link to get details about one of the search results and that takes you to another page. Because of the nature of the web's architecture, this request-response loop was pretty much required to interact with data hosted on the web. Ajax changes all that.

You want to see it in action before I get into how it works? Here are some examples:

  1. Zip Codes: A simple example. Enter a zipcode in the zipcode box. The page will automagically retrieve the city and state for that zip (a feature I wish every order form everywhere had right now).
  2. Google Suggest: Start typing in a search term, and Google will make suggestions about what you're typing. For instance, just try typing "Abra" as if you were going to search for "Abraham Lincoln".*
  3. A9.com: Amazon.com's new search engine. After you do a search, notice the buttons to the right of the page. They bring up results for different types of searches, like images, books, movies, etc. This happens without the page reloading. It's really very cool.
  4. [update: My first attempt, an Ajax-based search engine for this site. Rough around the edges, but still kinda cool and I made it in just a couple of hours. You can read more about it in the entry I made.]

Like I said, Ajax uses Javascript to send and receive information. That's a requirement for any of this to work. But generally it will also use XML as the medium for receiving information. This allows the web browser to be able to easily parse and use the information it retrieves. It can do all this because of the XMLHTTPRequest object, which is a Javascript object that can send and retrieve information. The XMLHTTPRequest object is a few years old, but only in the last year has the amount of browsers that support it reached the critical mass necessary for it to work on a large scale. As of this writing, Internet Explorer 6, Firefox and other Mozilla based browsers, Safari and Opera all support the object, though in keeping with Microsoft's hostility to open standards, IE implements it in a proprietary manner. But IE's method is similar enough that it's trivial to write cross-browser code. The decline of earlier versions of IE and the rise of Firefox and Safari are the reasons that the browser landscape has changed enough.

Another piece of the puzzle is an embrace of web standards. In order to be able to display new information, the web browser has to be able to modify the underlying structure of the webpage itself. In earlier days when table-based markup, font tags and spacer gifs dominated the land, the complexity of altering a web page dynamically was itself a barrier to the sort of things Ajax can do. But now that good, structured, semantically meaningful markup is becoming the norm for forward thinking programmers, radical changes to a web page can be made with very little effort. Clean code allows the programmer to easily manipulate the DOM, and modern methods for doing that manipulation are much more direct and efficient than older ways that employed such ghetto tactics as "document.write()".

It's really very, very cool technology, and the sort of thing that frustrated web developers like me have been waiting for. The two biggest barriers to the widespread adoption of any new web technology have always been browser support and user acceptance. CSS, for instance, was held back years because of the vastly different and often very buggy implementations of it in the major browsers. Flash, on the other hand, is implemented more or less the same across browsers, but it took years for it to be commonplace because it required the user to download and install a plug-in. And Flash is one of very few plug-in technologies that survived the test of user apathy (literally hundreds of others have fallen by the wayside). But serendipitously, Ajax has managed to sidestep both of these issues. It requires virtually no action on the part of the user except for the use of a modern web browser. And across the span of web browsers, it's implemented in a consistent enough fashion to be actually usable. All of this came about because the browsers that people use have quietly but dramatically changed over the last two years, despite the browser wars being "over".

So, over the next 12 months, I expect to see really neat magic tricks happening with this technology. Most users won't even know it's being employed, they'll simply notice that web pages just seem to "work" better. Surfing the web will be a little more like using a desktop application, doing complex things will be faster and easier, and they'll spend less time waiting for pages to load. But for the people who actually have to program this stuff, it's a breath of fresh air.

* Yes... Google again. Actually Google is quite an innovator here. Google Maps, Gmail and other new Google products are using Ajax to one degree or another. In the case of Maps and Gmail, they're basing the entire application on it, and the ways they are able to use it are simply jaw-dropping. And that's what I mean when I say Google is a leader. If it weren't for Google showing showing the rest of us that this stuff is ready for prime-time, most web developers, myself included, wouldn't trust this technology. I said it before, as Google goes, so goes the internet.

Blog Roll