Koakuma
asked on
ajax onreadystatechange parameter
I want to pass a parameter to the callback function to identify one ajax call from another.
This code is not doing the business. Is it possible? How is it done?
This code is not doing the business. Is it possible? How is it done?
function runscript(page, data, element)
{
//get ajax object
HTTPrequest[req_no]=GetHTTPrequestObject();
// set callback
HTTPrequest[req_no].onreadystatechange=stateChanged(req_no);
//check there is a connection to server
if (HTTPrequest[req_no]==null)
{
alert ("Browser does not support HTTP Request");
return;
}
info['ajax'] += 1;
info['script'] = page;
//create script url
var url=page+".php";
url=url+"?element="+element;
for(i in data)
{
url=url+"&"+i+"="+data[i];
}
url=url+"&sid="+Math.random();
//load the script
HTTPrequest[req_no].open("GET",url,true);
HTTPrequest[req_no].send(null);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.