Reset password:

Strategic insights
AJAX, XMLHTTPRequest or AHAX

Written by on December 4, 2005

Some of you might have wondered why I rarely refer to the term AJAX. The answer is quite simple. I rarely use it, but I often use XMLHTTPRequest. Let me explain that.

Ajax is short for "Asynchronous JavaScript + XML", which basically means that:

Asynchronous

You interaction must be asynchronous, meaning that the client and server must work independently - and communicate independently. Or, as Adaptive Path puts it "without stalling a user's interaction with the application."

But, very few applications that claim to use AJAX are asynchronous. To give you an example take "Remember the Milk" - An excellent AJAX application. Well, it is an excellent application, but apart from the sign-up page, it is not an AJAX application.

When you add a new task (to do), you have to wait until the task has been saved before you can continue your work. Granted it does save and refreshes the task list, without having to reload the page. But, it does not function "without stalling a user's interaction with the application".

"Remember the Milk" is using synchronous interaction (just like most other so-called AJAX applications). It is just done in a very fancy way. It is an XMLHTTPRequest application.

JavaScript

The JavaScript part is fine for many applications, but I only use JavaScript in 25%. XMLHTTPRequest is not limited to JavaScript, you can use other scripting languages as well - and I do just that.

JavaScript is fine when you have to target the public, but when you have control over environment your users is working in, as in specific projects or in-house applications, you will be much better of using other languages. JavaScript is slow.

XMLHTTPRequest is also not limited to the client; you can use it on the server, which offers you great advantages when dealing with content from multiple sources. Of course, on the server, JavaScript is not an option.

Not to mention that XMLHTTPRequest is not limited to browsers either. You can use it in applications as well. This allows you to handle internet based data sources as local data - one example is the task-pane "Research" in Microsoft Office.

XML

XML sounds very good. Everybody talks about it. It is the next thing in almost every new product - and it is a standard too. But why use it in the browser? I understand why you want use on the server, also why you want use to store documents of database content. With XML you get the content and the structure in an extremely flexible format.

But, in your "AJAX" applications do you ever send XML data? I am guessing no - I know I have never done that.

To save XML data you have to get the value from your form field, wrap into XML tags, and send it to the server. The server then has to unwrap it, and put in the database. It is much easier to simply send only data, and leave out all the XML stuff.

This is also what most people do. Sending XML is not a feasible solution. That is unless you are in a situation where you have to send more than one form field - like the complete contents of a table.

What about receiving XML data? I know a lot of who do just that. But, for me that is equally impractical.

I have seen examples where people would have a complex PHP/ASP script that would turn output from a database into XML. This is then sent to the client, which has an equally complex JavaScript script, which turns the XML into HTML - or simply pure data.

What a waste of efforts. What you have is pure data in your database, which you want outputted as either pure data, or HTML. Why go trough all that XML stuff? You do not need it. You can do the same much faster without.

Why not just have the server generate HTML directly, and send that. Then the client does not have to do a thing. It is still XMLHTTPRequest but, it is a 70-80% speed increase.

Use AHAX instead of AJAX

AJAX is a good idea. The asynchronous part is brilliant, although not always practical. But AJAX is also very limited - and slow.

Instead consider AHAX (since the web community seems to need acronyms). AHAX is short for "Asynchronous Handling + XMLHTTPRequest". The concept is the same as AJAX, but without its many limitations.

You still need to make your applications asynchronous (truly separate the user from any client-server interactions). You are not limited to a single script or programming language and you are not limited to a single data format.

AHAX can be used on both the client, the server, and in normal applications. I have never really used AJAX, but I use AHAX in 90% of my recent projects.

Read also:

Share on

Thomas Baekdal

Thomas Baekdal

Founder of Baekdal, author, writer, strategic consultant, and new media advocate.

Follow    

Baekdal PLUS: Premium content that helps you make the right decisions, take the right actions, and focus on what really matters.

There is always more...

The Economics of Individual Media »

ONLY FOR
SUBSCRIBERS

31
PAGES

What if Quality Journalism Isn't? »

ONLY FOR
SUBSCRIBERS

21
PAGES