It's part of an AJAX segment of code that should retrieve information from a publisher program that I'm a part of. It gets called from the page a dynamically produced number of times, but each time it's called like this:
sendRequest(url1, 1)
sendRequest(url2, 2)
sendRequest(url3, 3) etc.
Here are the relevant segments of code in javascript (i'm not going to include the creation of the XML object to begin with, i know that the problem is not there):
function processRequest(num)
{
if(xmlHttp.readyState == 4){
var response = xmlHttp.responseXML;
alert(num);
x = response.documentElement.getElementsByTagName("productResponse");
xx=x[0].getElementsByTagName("name");
txt=xx[0].firstChild.nodeValue;
theId="serverResults" + num;
e = document.getElementById(theId);
e.innerHTML=txt;
}
}
function sendRequest(url, number)
{
xmlHttp.open('get', 'mediatorscript.php?x=' + url);
xmlHttp.onreadystatechange = function() { processRequest(number) }
xmlHttp.send(null);
}
I know, or at least I think, that the problem is that the function() { processRequest(number)} is not acting how I want it to. Can someone tell me what I should be doing?