"Ajax" is a new term which is spelled by almost all the web developers today! Does everyone know that it uses
XmlHttpRequest internally? Many say "Yes", some people say "don't know". I am writing this article for all the developers who must understand
XmlHttpRequest which I consider to be the backbone of Ajax.
What is Ajax?
Ajax is not really a technology, it is an architectural pattern. It is not another name for
XmlHttpRequest, but a technique to call the server with the help of
XmlHttpRequest, CSS, DOM, XML, HTML and other web entities.
Who is the Inventor of Ajax?
The answer is 'Nobody'. Although it is a design approach, no specific person or company owns it. "Jesse James Garrett" is the founder of this name. He used the combined web design approach in his applications, and he named it "Ajax". Google made Ajax famous, because we use Gmail and Google map interface on a day to day basis.
In this article, I'm going to concentrate on
XMLHttpRequest, the backbone of Ajax. For further details on Ajax, you can refer to this link.
Flow of the XmlHttpRequest
A Quick Example
I am not going to create an ASP.NET web project. Since
XmlHttpRequest is common in all the web applications, everyone should understand what it is.
Here, I am going to explain how to call the HTML data from one page to another page.
Create the First HTML Page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Calling another page</title>
client = new XMLHttpRequest();
else if (window.ActiveXObject)
client = new ActiveXObject("Microsoft.XMLHTTP");
client.onreadystatechange = callBack;
if(client.readyState == 4 && client.status == 200)
<h4>Reading server response Using XMLHttpRequest</h4>
Server URL: <input id="txtURL" type="text" value="HtmlPage2.htm" />
<input type="button" value="Call" onclick="doCall()" />
Create the Second HTML Page
Testing the Sample
Try to click that button; you can see "Hello World" text appear in bold, this is actually a response from the server. Try to give other URL in the text box; for example: http://www.codeproject.com, you will get an error message "Permission denied." Normally you can't call across the server because it's a security issue, your browser will not allow you to perform this operation. You can call only within a server.
Using the above approach, you can also read a response from any ISAPI applications such as ASP, ASP.NET, PHP, and JSP.
How Does Ajax Use This?
XmlHttpRequest. This is the reason why many people do not know about the classic
Does Ajax Create a Bottleneck in the Performance?
Please read this article regarding performance problems of Ajax.