PDA

View Full Version : Help In Ajax .. Creating Multi Instance Of XMLHTTPRequest



shehabic
01-13-2006, 12:44 AM
What I'm Asking About Can I Send 2 Requests At The Same Time .. And They Work In Parallel ?? Example If There's 2 Polls In 1 Page .. And Someone Clicked On The 1st One And Click On The 2nd Before The 1st One Is Finished ... is It Possible To Make Array Of Requests ??? The Below Code Doesn't Work .....If I Just Got The Response I Can Handle It Later But Please Tell Me How To Create multi Instance Of The XMLHTTPRequest ...


var req=new Array();
var The_ID=new Array();
// The_ID is An Array Containing The IDs Of Any HTML Part That The Result Of Any Request Will be Executed At E.g Any TD Or something in any table in the HTML ...
function sR(url,params,HttpMethod,anyID){
if (!HttpMethod)
{
HttpMethod="POST";
}
The_ID[req.length]=anyID;
req[req.length]=initXMLHTTPRequest(); // The Problem Is Here ..
for (i=0;i<req.length;i++)
{
if (req[i]){
req[i].onreadystatechange=onReadyState(i);
req[i].open(HttpMethod,url,true);
req[i].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req[i].send(params);
}
}
function initXMLHTTPRequest(){
var xRequest=null;
if (window.XMLHttpRequest)
{
xRequest=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
else {
}
return xRequest;
}
}