admin管理员组文章数量:1355642
What is the difference between async=false
and async=true
, when I am using open
method of XMLHttpRequest
?
function GetXML() {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = test
xmlhttp.open("GET", "PlanetCafe.xml", true);
xmlhttp.send(null);
}
What is the difference between async=false
and async=true
, when I am using open
method of XMLHttpRequest
?
function GetXML() {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = test
xmlhttp.open("GET", "PlanetCafe.xml", true);
xmlhttp.send(null);
}
Share
Improve this question
edited Mar 21, 2013 at 15:23
Danny Beckett
20.9k26 gold badges113 silver badges142 bronze badges
asked Mar 13, 2013 at 7:39
TheChamppTheChampp
1,4375 gold badges25 silver badges41 bronze badges
1 Answer
Reset to default 8Mozilla Developer: Synchronous and Asynchronous Requests
XMLHttpRequest
supports both synchronous and asynchronous munications. In general, however, asynchronous requests should be preferred to synchronous requests for performance reasons.In short, synchronous requests block the execution of code and can leak memory and events. This can cause serious issues. The only viable reason to use synchronous requests is to more easily facilitate downloads within
Web Workers
.
本文标签:
版权声明:本文标题:javascript - What is the difference between a synchronous and an asynchronous request? (async=truefalse) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743951833a2567433.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论