Ajax the Great, son of Telamon, was a Greek hero of the Trojan war. True but he is not the subject of this blog.
Ajax is a liquid or powdered industrial cleaner. Correct but I don’t want to blog about this either.
Ajax is a Dutch football team. Well, this statement is true as well but if I wanted to blog about a big European football team, I’d write about Galatasaray.
These previous points aside, AJAX is probably the most hyped acronym these days. It stands for Asynchronous JavaScript And XML (Jesse James Garrett of Adaptive Path is the one who came up with the term in 2005). So, it is about transferring XML data asynchronously using JavaScript. Let’s elaborate on this:
In desktop application development, we would use multi-threading not to block the user interaction while waiting a task to finish. However, the classic browser interaction model based on HTTP request-response paradigm lacks that richness. The data is submitted after a click and a full page is loaded synchronously. So, finally we found a way to make the Web experience more interactive and this is thanks to AJAX, right? Not really… Long before AJAX became popular, Netscape 4 and IE 4 introduced DHTML (Dynamic HTML). An enhancement over the classic Frameset was the IFrame. The “I” in IFrame stands for “inline” because the frame belongs to the layout of another document instead of being part of a frameset. So, what we did was to create an invisible IFrame in order to contact the server in the background, achieving the asynchronicity. Lesson 1: Before AJAX existed, we knew how to do asynchronous calls to the server. It felt more like a workaround but it did the job.
Later, in Internet Explorer 5, Microsoft implemented an ActiveX object called XMLHttpRequest that was accessible via JavaScript. Mozilla project implemented a native version of XMLHttpRequest in Mozilla 1.0 and Netscape 7.0. Apple has done the same thing starting with Safari 1.2. What was the job of XMLHttpRequest? Asynchronous XML data exchange. Lesson 2: Long before the name AJAX appeared, the underlying XMLHttpRequest object had been around.
Now we have very interactive public Web applications using AJAX. We can interactively create an online photo album or create our web page or spell-check our message before sending, etc. All these killer apps use asynchronous calls to communicate with the server in the background while we can do something else. However, the visible part of the GUI, the most impressive part to the ordinary user is not asynchronous XML data exchange, it is DHTML. The richness of the user interface didn’t come with AJAX, it came with DHTML. And, there’s been alternative technologies, such as Java Applets and Flash to create rich clients. Lesson 3: JavaScript, CSS and the DOM provides all the bells and whistles for the new cool interactive Web applications.
So, is AJAX merely an object used by the browser to do XML data exchange with the server asynchronously? Well, not really. AJAX became more than just Asynchronous JavaScript And XML. We need asynchronous requests, JavaScript, CSS and DOM to have an AJAX application however we can use all of them without doing AJAX. Lesson 4: AJAX is a different Web interaction model. In an AJAX application, the workflow is at least partly contained by the client application and asynchronous XML requests are used in the background while the user performs other tasks. This model can become more complex, just like in Google GMail where the entire application is an interactive system.
For us, the developers, AJAX development comes with various challenges. It requires studying some of the AJAX design patterns. Suddenly JavaScript code becomes the centrepiece of an intelligent client (back to the thick-client days?). Now we’re brought to consider our JavaScript code from different angles: reliability, maintainability and flexibility. Furthermore, there is a fast growing market for AJAX frameworks. Some of them are maturing fast (ZK, Rico, Zimbra, etc.). We need to keep an eye on them not to reinvent the wheel. And for the tooling, give a try to Eclipse WTP (Web Tools Project) + AJAX Toolkit Framework. This couple will give you enough ammunition to start your first AJAX project.
- Yagiz Erkan -