解决方法
XMLHttpRequest supports both synchronous and asynchronous communications. 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.
异步请求是XMLHttpRequest存在的主要原因. XMLHttpRequest支持AJAX,其思想是让JavaScript代码运行,并且您的用户在您的JavaScript与后台服务器通信的同时对您的页面执行任何操作.例如,Gmail会以这种方式加载您的电子邮件.
传输完成时,同步请求会阻止脚本运行.简而言之,当异步请求可用时,没有理由这样做.如果你的Gmail一直冻结,那会很烦人,你不觉得吗?您很少(如果有的话)想要使用同步请求.
There are circumstances you must use a synchronous request,但在这些情况之外,您可能完全没有理由提出同步请求,并且完全没有理由使用异步请求.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。