input for stateChanged()
Posted: Tue Apr 13, 2010 11:25 pm
Hi
When I want to define input variable for stateChanged, my code doesn't work
I don't want to define lots of stateChanged functions. How can I fix it?
This code doesn't work:
But this code works fine:
When I want to define input variable for stateChanged, my code doesn't work
I don't want to define lots of stateChanged functions. How can I fix it?
This code doesn't work:
Code: Select all
function loadrealms(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="ajaxphp.php";
url=url+"?action=loadrealms®ion="+str;
xmlhttp.onreadystatechange=stateChanged('realmoptions');
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged(div_id)
{
if (xmlhttp.readyState==4)
{
document.getElementById(div_id).innerHTML=xmlhttp.responseText;
}
}Code: Select all
function loadrealms(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="ajaxphp.php";
url=url+"?action=loadrealms®ion="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("realmoptions").innerHTML=xmlhttp.responseText;
}
}