you need to pass the reference of the xmlHttpObject or it will not be present because of the scope.
Code:
function GetUrl(striurl)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url=strurl;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged(xmlHttp);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(&state)
{
if (state.readyState==4)
{
document.getElementById("mydiv").innerHTML=state.responseText;
}
}
or you could do the state change processing without changing functions
Code:
function GetUrl(striurl)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url=strurl;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange= function () {
if(xmlHttp.readyState ==4)
{
document.write(xmlHttp.responseText);
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
Bookmarks