If it helps, here is some code. There are 3 files, a normal HTML page
that has the buttons, an external Javascript file (see below), and a
simple ASP file that does some dummy calculations to "waste time" and
then sends a Response.Write back to the page that started things...
Here is the .js:
function update_log(t,num)
{
document.getElementById('put_here').innerHTML =
document.getElementById('put_here').innerHTML +
' <br>' + t + ' [# of connections: ' + parseInt(xmlreqs.length+num)
+']'
}
function sendData(l,x)
{
update_log('<b><i>Button "' + l + '" clicked, Sending
Request</i></b>',1)
var queryString = 'AJXloops=' + x + '&AJXaction=' + l
var url="respond_main_03a.asp";
xmlreqPOST(url,queryString)
}
//
------------------------------------------------------------------------------------------------
// Based on Code from
http://www.drakware.com/articles/multijax.php
//
------------------------------------------------------------------------------------------------
var xmlreqs = new Array();
function CXMLReq(type, xmlhttp)
{
this.type = type;
this.xmlhttp = xmlhttp;
}
function xmlreqGET(url)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla, etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
// IE
else if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
if(! xmlhttp)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}
function xmlreqPOST(url,data)
{
var xmlhttp=false;
if (window.XMLHttpRequest)
{
// Mozilla etc.
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
else if (window.ActiveXObject)
{
// IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp)
{
xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlhttp.send(data);
}
}
var xmlreq = new CXMLReq('', xmlhttp);
xmlreqs.push(xmlreq);
}
function xmlhttpChange()
{
if (typeof(window['xmlreqs']) == "undefined") return;
for (var i=0; i < xmlreqs.length; i++)
{
if (xmlreqs[i].xmlhttp.readyState == 4)
{
if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status ==
304)
{
// 200 OK
update_log(xmlreqs[i].xmlhttp.responseText,-1)
xmlreqs.splice(i,1); i--;
}
else
{
// error
xmlreqs.splice(i,1); i--;
alert("A problem occurred!");
}
}
}
}