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.XMLHT TP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
var output;
xmlHttp.onready statechange=fun ction()
{
if(xmlHttp.read yState==4 || xmlHttp.readySt ate=="complete" )
{
output = xmlHttp.respons eText;
}
}
xmlHttp.open("P OST",page,false );
xmlHttp.setRequ estHeader('Cont ent-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(da ta);
return output;
}[/HTML]
It works in firefox 2 (with firebug installed and enabled) but onreadystatecha nge 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.respons eText;" line to use a callback function like most online examples do, but still no joy.
Cheers
Andy
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.XMLHT TP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
var output;
xmlHttp.onready statechange=fun ction()
{
if(xmlHttp.read yState==4 || xmlHttp.readySt ate=="complete" )
{
output = xmlHttp.respons eText;
}
}
xmlHttp.open("P OST",page,false );
xmlHttp.setRequ estHeader('Cont ent-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(da ta);
return output;
}[/HTML]
It works in firefox 2 (with firebug installed and enabled) but onreadystatecha nge 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.respons eText;" line to use a callback function like most online examples do, but still no joy.
Cheers
Andy
Comment