- HTML
- XML
- JSON
- Text
I’m going to examine each data format so that you can make an informed decision as to
which one best suits different kind of applications. I will have sample for each one format.
var xmlHttpRequest;
function getXmlHttpRequestObject()
{
if(window.ActivexObject)
{
return (new ActivexObject("Microsoft.XMLHTTP"));
}
else if( window.XMLHttpRequest)
{
return(new XMLHttpRequest());
}
else
{
return null;
}
}
function sendRequest() {
xmlHttpRequest = getXmlHttpRequestObject();
xmlHttpRequest.onreadystatechange = handleResponse;
xmlHttpRequest.open("GET", "data_message.html", true);
xmlHttpRequest.send(null);
}
function handleResponse() {
if (xmlHttpRequest.readyState == 4) {
alert(xmlHttpRequest.responseText);
}
}
new ActiveXOjbect("Microsoft.XMLHTTP");Garrett coined the term Ajax (Asynchronous Java-Script and XML) to describe techniques used to build new kind of Web application.
While the first letters of these words map very neatly to the cool name, they aren’t very effective in describing the technologies in question.
The X for XML is particularly problematic. It implies that XML is a requirement for Ajax applications. This simply isn’t true. To be fair, the letters XML also appear in the word XMLHttpRequest (the core technology used in most Ajax implementations), but XMLHttpRequest doesn’t sound very cool.
The XMLHttpRequest object is an extension to JavaScript that allows Web pages to communicate with a server. It’s perfect for creating Ajax applications. The XMLHttpRequest object is the engine that drives Ajax, but it doesn’t exist in a vacuum.
XML, which stands for eXtensible Markup Language, is a format for describing data. Ajax applications require some kind of structured format to deliver information from the server to the client. But XML is just one option. As we’ll see later on as we explore more, there are other ways of structuring data that are equally viable for Ajax.
This is one of the important aspect to understand.

XMLHttpRequest object is created and configured with a request parameter that includes the ID of the component that generated the event and any value that the user might have entered.XMLHttpRequest object makes an asynchronous request to the web server. An object (such as a servlet or listener) receives the request, processes it, and stores any data in the request to the data store. In the case of Ajax-aware JavaServer Faces components, the object that processes the request is a PhaseListener object. We'll cover that more later in the document.XMLHttpRequest object receives the XML data, processes it, and updates the HTML DOM representing the page with the new data.