Is foo below safe if it is called twice in quick succession such that the second call occurs before the first response is received ? If it is safe could you please explain the mechanism behind how the correct "param" value gets matched to the correct "xmlHttp" response ?
function foo (param)
{
var xmlHttp = GetXmlHttpRequestObject();
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
// do something involving param and xmlHttp.responseXML
}
}
xmlHttp.open("GET", "GetAsyncData.ashx", true);
xmlHttp.send();
}