tokatrash
Programmer
- Jan 3, 2009
- 1
Hi all,
First of all, I know that you have probably seen this question before. I have read the answers, but is not able to see what I am doing wrong within my code.
What I am trying to do is to pass a variable holding the name of a element id I would like to change.
Hope that you are able to point out what i am doing wrong!
Thanks a lot!!
Here is the code:
------------------------------------------------------------
var xmlHttp
function dom_seek(str, str_name)
{
if (str.length==0)
{
document.getElementById(str_name).innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="dom_status.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange = function(str_id) {
return function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById(str_id).innerHTML=xmlHttp.responseText;
}
}
}(str_name);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
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;
}
------------------------------------------------------------
First of all, I know that you have probably seen this question before. I have read the answers, but is not able to see what I am doing wrong within my code.
What I am trying to do is to pass a variable holding the name of a element id I would like to change.
Hope that you are able to point out what i am doing wrong!
Thanks a lot!!
Here is the code:
------------------------------------------------------------
var xmlHttp
function dom_seek(str, str_name)
{
if (str.length==0)
{
document.getElementById(str_name).innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="dom_status.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange = function(str_id) {
return function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById(str_id).innerHTML=xmlHttp.responseText;
}
}
}(str_name);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
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;
}
------------------------------------------------------------