What is AJAX? And why we (don't) use AJAX...

Michael Schwarz on Monday, August 8, 2005

I read the blog from Wallace What is AJAX [1]? Yes, what is AJAX and why do we want to use AJAX?

<li><font size="2">We have to use AJAX because everyone is talking about it!</font> <li><font size="2">We have to use AJAX because big companies (Google, Amazo, Microsoft) are using AJAX!</font> <li><font size="2">We have to use AJAX because it is faster than have a postback for each call!</font> <li><font size="2">We have to use AJAX because...</font></li> BUT: Are we using AJAX? Have a look on the name of AJAX [2]: Asynchronous JavaScript and XML. If you ever used my Ajax.NET library you are not using AJAX!! I started the Ajax.NET library after I have read the article A New Approach to Web Applications [3] (Jesse James Garrett, adaptive path). Before the library was called CSharpWrapper [4]. Changing the name to Ajax.NET and adding more features was the correct decision at the right time. Inside it is the same, I'm using the XmlHttpRequest to transfer data to and from the server without a postback (and a complete page reload).

If you have a look inside the Ajax.NET library you can see that I'm not using XML to transfer the data to or from the server. I am using the JSON [5] syntax because it is supported by I think all modern browsers including Pocket IE (Windows Mobile). It is very simple and you can get a real JavaScript object using one command: eval [6].

In the future we will use the XmlHttpRequest to post and get data from the server using the HTTP protocol, synchronous or asynchronous. We will serialize the data (objects) using strings (JSON), XML or maybe binary data. On the client we are using JavaScript to change parts of the web page using DHTML/DOM.

The conclusion is: AJAX is still a cool name! Now, that we have the acceptance of developers and web designers we should concentrate us on the correct usage of the XmlHttpRequest object. I still get strange questions concerning the Ajax.NET library because of missing understanding how HTTP, postbacks and browsers are working.