ajax xmlhttp request object
Posted: Mon Dec 18, 2006 9:12 pm
feyd | Please use
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi,
i'm using the code below to make asynchronous ajax calls to a server. it works with firefox but on IE6 i get an alert pop-up saying 'no request object'. does any of you know a fix for this, or can point me to a better script?
[syntax="javascript"]
function createXmlHttpRequestObject()
{
var xmlHttp; //stores ref to the XMLHttpRequest object
/** for non IE6 or older browsers **/
try {
xmlHttp = new XMLHttpRequest();
}
catch(e) {
//assume IE6 or older
var xmlHttpVersions = new array ("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
//try every prog until one works
for (var i=0; i<xmlHttpVersions.length && !xmlHttp; i++) {
try {
xmlHttp = new ActiveXObject(xmlHttpVersions[i]);
}
catch (e) {}
}
}
/*********** for all other browsers ****************/
if (!xmlHttp)
alert('error creating the XMLHttpRequest object.');
else
return xmlHttp;
}
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]