2017-09-05 24 views

回答

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>