hi guys,
My code suddenly stopped working
here it is:
[HTML] function Ajax(page,data){
page = "includes/" + page;
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
var output;
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
output = xmlHttp.responseText;
}
}
xmlHttp.open("POST",page,false);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(data);
return output;
}[/HTML]
It works in firefox 2 (with firebug installed and enabled) but onreadystatechange doesnt seem to get called in IE (7 and before) and firefox 3.
Can anyone see why?? It has been working fine and I dont think ive changed this function but after an afternoon of debugging ive narrowed it down to this error. I also just tried replacing the "output = xmlHttp.responseText;" line to use a callback function like most online examples do, but still no joy.
Cheers
Andy