Shut Useless header
Shut your eyes, and look again, the whole world has gone upside down.
  • Twitter
  • LinkedIn
  • Ayyash

To AJAX or not to AJAX

When is it a pain in the neck?!

| Boiler Room

Years ago when I started my professional career, I used to apply every new technology I put my hands on, on my homepage or on the current project I would be working on. Now I have grown up, and have grown out of it!

It was clear to me that the less technology on a page, the better, and more friendly. Well, this new AJAX is another temptation that I am proud to say I defeated.

When first I learnt what AJAX was, I couldn't find the real difference between AJAX and Remote Scripting. Then it turned out to be an ActiveX object instead of a Java Applet, and I couldn't help but recalling the famous Mircosoft WebSerivce Behavior (on MSDN), an HTC file that Microsoft provided for free, that does exactly what Remote Scripting used to do, and maybe more. But now, all over the web, some smarties are claiming they now have this new thing, and they have called it AJAX!

It is a great method, the asynchronous JavaScript and XML, but it has been there for years, Microsoft has its Outlook web-based solution built on this concept, and when you saw a dialogue window open in Outlook web-based, know that you were face to face with this so-called AJAX (I found that out by looking at the code and trying to figure out how they solved the issue of posting back inside a dialogue window.)

I also have run across some sites that claim they had their own way of replacing AJAX XML object, by inserting a script tag on runtime, and assigning a source (src attribute) to link to another PHP file. Well it does work, but all it does is when you click to call, it fetches "content" and displays. What is so AJAX about that? I believe when it comes to displaying content dynamically without refreshing the page, AJAX is not very helpful. In the past, we used to have an iFrame for that, then we had a hidden iFrame and a division that gets updated with the contents of the iFrame (how ridiculous). Then we had this building scripts on runtime method, another ridiculous, full of dangers method.

But then, then came Microsoft with CSS behaviors. Microsoft published a number of default behaviors in the browser, and one of them (very little know about it), is called the "download" behavior. Its syntax looks like this:

behavior: url(#default#download)

And once in use, you can call the "startDownload" method of the attached element. That would download a static HTML file content, that you can catch and display anywhere on your web page.

AJAX is helpful in places you need to interact with the server and save data without leaving your page. Displaying content dynamically is by far the least useful thing, and when you hit "back" button and see what happens, you are going to hate it even more.