日期:2014-05-16 浏览次数:20374 次
var run = function()
{
var timeout = 0;
if(interfaces.length == 0)
{
return;
}
var interface = interfaces[0];
if(autoXMLHttp != null)
{
requestTime = new Date();
autoXMLHttp.open(METHOD, TESTING_URL, true);
autoXMLHttp.onreadystatechange = function()
{
if (autoXMLHttp.readyState === 4 && (autoXMLHttp.status === 200 || autoXMLHttp.status === 304))
{
alert(interface.actionCode);
responseTime = new Date();
if(interface.callback != null)
{
timeout = interface.callback(interfaces,autoXMLHttp);
}
autoCreateHistory(interface.actionCode,interface.content,requestTime,autoXMLHttp.responseText,responseTime);
//如果队列中还有请求,就接着递归执行executeAjax函数,直到队列为空
if (interfaces.length > 0)
{
//删除队列中的第一个请求
interfaces.shift();
setTimeout(run,timeout);
}
}
}
autoXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
autoXMLHttp.send(interface.content || null);
}
}
run();
if(!autoXMLHttp.onreadystatechange)
autoXMLHttp.onreadystatechange = function(){}