All pastes #420868 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-02 13:39 UTC
rendered paste body
function retrievedData(i) {
	if (xmlReq.readyState == 4) {
		if (xmlReq.status == 200) {
			alert(i + "\n" + xmlReq.responseText);
			// or use xmlReq.responseXML for a DOM tree of an XML response
		} else {
			alert(xmlReq.status + " error");
		}
	}

}

var i=0;
while((item=object(i))!=null)
{
	if (item.value==1)
	{
		xmlReq = new XMLHttpRequest();
		xmlReq.open("POST", "http://www.abc.com//"+item.name);
		xmlReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
		xmlReq.onreadystatechange = function() { return retrievedData(i); };
		xmlReq.send("blahblah")
	}
	i++;
}
//1. I have no idea how to handle this retrieveData...
//2. The complete loop looks ugly, each time a new XHR opject?