I recommend to use jQuery or other framework, that will be always aware of all the browsers specific stuff.
If you prefer to use native code, you will need some extra code. First, dont rely just in ActiveXObject("Microsoft.XMLHTTP");
and XMLHttpRequest
that probably wont be always available. instead of that, use:
function GetXmlHttpObject(){
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
var xmlhttp=GetXmlHttpObject();
then you define your callback:
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
and send it, but i would include a random variable in the url, to ensure that the browser is not caching anything
xmlHttp.open("GET",url+"&sid="+Math.random(),true);
xmlHttp.send(null);
Anyways, probably your problem has nothing to do with the ajax itself, and probably there is something else in your code causing everything to crash.
For example, take a look at the chrome console, and im sure you will have some useful informtion in the error log. if you dont know how, here you have a guide
solved Ajax Doesn’t work in Chrome,Firefox, & Opera