function startAR()
{
for (var a = 0; a < 100; a++){
executeAR();
}
};
考虑到executeAR()对服务器请求异步使用XmlHttpRequest,有多少 在这个循环中可以实现最大同时请求吗?
答案 0 :(得分:0)
您可以使用以下示例来确定和计算XmlHttpRequest。使用您的谷歌浏览器控制台(导航到网络),看看请求将是100次。
function loadXMLDoc() {
for(var i=0;i<100;i++){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "xmlhttp_info.txt", true);
xhttp.send();
}
}
<!DOCTYPE html>
<html>
<body>
<h2>Using the XMLHttpRequest object</h2>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
<p id="demo"></p>
</body>
</html>