Following are the steps that how you can code the Ajax Application:
Firstly, how to create an XMLHTTPRequest object. This process is different to some extent depending on your Internet Explorer that either it is (5+) with ActiveX enabled, or a standards-compliant browser for example Mozilla Firefox.
With IE, the request looks like:
http = new ActiveXObject(”Microsoft.XMLHTTP”);
Whereas in a standards-compliant browser we can instantiate the object directly:
http = new XMLHttpRequest();
Secondly, you have to write an event handler. The event handler will use different methods of XMLHTTPRequest object to:
• make the request of the server
• check when the server says that it has completed the request, and
• deal with the information returned by the server
you can make your request of the server with the help of GET method to proper server-side script. See the example of event handler called updateData which suppose that you have defined your object of XMLHTTPRequest and now called it as http:
function updateData(param) {var myurl = [here I insert the URL to my server script];
http.open(”GET”, myurl + “?id=” + escape(param), true);
http.onreadystatechange = useHttpResponse;
http.send(null);
} Thirdly, you need a function of useHttpResponse that create when server is completed your request, and then perform an action with the data it has returned:
function useHttpResponse() {if (http.readyState == 4) {
var textout = http.responseText;
document.write.textout;
}
}
Tags: How the AJAX coded



english
español
Deutsch
français
Italiano
Português
русский










One comment
Leave a reply