How to Create XMLHTTP object
Before we start to code in ajax, we should know how to create XMLHTTP object. For example if we create like this
http_request = new XMLHttpRequest();
It will work only in mozila type browsers, it won’t work in IE..
Following code will show you how to create XMLHTTP object,
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType(’text/xml’);
}
} else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try {
http_request = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (e) {}
}
}
In the above code if block is used to create object for mozila type browser.
Then the else block shows how to create an object for IE browsers.
