What is Ajax?
I’ve been getting this question quite a bit lately – especially as people find out about Foundations of Ajax. Obviously I’m not the first to talk about this but I’ve developed a bit of a stock answer so here goes. Don’t agree with something I’ve said? Let me know!
At this point you might be saying “so what, I’ve done this for years.” Truth be told, none of the technologies that Ajax represents are new – however, the widespread browser support is. Many people (including me) have used iframes to call the server in the background or to submit/repaint just part of the page. I’ll admit, it works fine, but truthfully it’s a hack. Today, thanks to modern browsers allow us to take advantage of a Microsoft invention – the XMLHttpRequest object (XHR for short). XHR provides a simple mechanism that allows us to call the server and tie the response to a callback function. With improved DOM support, we can take data from the server and modify just part of a page.
This means we don’t have to refresh the entire page just to fill in one or two fields. A minor thing maybe, but it really opens up some new possibilities. Like what you might ask? Well, take a look at two of my favorite examples – the browse section of Netflix and Google Maps. With Netflix, just hover over any box cover. A “tool tip” containing a significant amount of information pops up. Go ahead, view the source, the information in the bubble isn’t hiding in the page – it’s requested when you mouse over a specific movie.
What makes Google Maps so special is the scrolling. Want to see what’s off the map? Just use your mouse to drag the map. That’s it. No repaint like Mapquest. John Carroll glosses over this point in his blog on Google Maps and innovation but I really think the drag makes Google Maps so special. And it’s not rocket science! The lads at Ajaxian (Ben Galbraith and Dion Almaer) whipped out a version in less than 2 hours at a conference. Don’t believe me? Check out their piece “Ajax is rocket science”. “Ajax isn’t simple”. Enough already!
In a nutshell, Ajax is a technique that allows us to create richer web applications – applications that are often indistinguishable from their thick client cousins. It certainly won’t end world hunger or even guarantee you’ll make it home in time for dinner, but Ajax will certainly influence what we build over the next few years. We’re only just starting to explore Ajax and what it means but I’m convinced it will ultimately make our web applications more responsive and improve usability.