How Ajax works

While the term Ajax was introduced in 2005, the technique of using XMLHttpRequest object was known since 1999 (this object became available in Internet Explorer 5). But up till now XMLHttpRequest object was never standardized by World Wide Web Consortium. This technically means that each Web Browser vendor can implement it differently.

Such Internet giants as Google, Yahoo, Amazon started using Ajax in their applications, which brought interest of business application developers who always wanted to make their Web applications less static and minimize page refreshes. A discussion on usability of Ajax for business applications is out of the scope of this article.

When I was learning how to work with AJAX, I went through a number of 101-type articles. The biggest problem with these tutorials is that the authors are trying to explain several things at once, which is confusing. I’ll try to offer you a very simple example of an Ajax application that will illustrate the “refreshless” nature of Ajax. Here’s a simple HTML page:

Click on the link, and the text area will be populated with the content of the server side file, which in our example has the text “Hello from the server!”

What’s the big deal? There is no entire Web page refresh! The XMLHttpRequest object sends an asynchronous request to the server, gets the data back and changes the content of just one object on this HTML page – the text area.

<form name="myForm">
<a href="">Read more...</a></form>Yakov