Click to See Complete Forum and Search --> : Having problem with getXMLHttpRequest function


tr_shuvo
05-10-2008, 09:30 AM
Hi,
I am having problem with getXMLHttpRequest function given below. In local server the function works fine but i have tried this function in a google map based application and then the function do not support IE7 but it works fine in opera. What can i do to make my page ajax compitable in IE7?

function getXMLHttpRequest()
{
var request, err;
try {
request = new XMLHttpRequest(); // Firefox, Safari, Opera, etc.
}
catch(err) {
try { // first attempt for Internet Explorer
request = new ActiveXObject("MSXML2.XMLHttp.6.0");
}
catch (err) {
try { // second attempt for Internet Explorer
request = new ActiveXObject("MSXML2.XMLHttp.3.0");
}
catch (err) {
request = false; // oops, can’t create one!
}
}
}
return request;
}

Hack
05-15-2008, 09:19 AM
What does it do when it runs in IE7?

CyberDragon
05-29-2008, 01:12 PM
This is what i tend to use simple yet works great for me.
function createRequest(){
try {
request = new XMLHttpRequest();
} catch (trymicfosoft) {
try {
request = new ActiveXObject("Msxm12.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
alert("Object could not be created");
}
}
}
if (request == null)
alert("Error creating request object!");
}