弃用同步 XMLHttpRequest [英] Deprecation Synchronous XMLHttpRequest
本文介绍了弃用同步 XMLHttpRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到此错误:[弃用] 主线程上的同步 XMLHttpRequest 已弃用,因为它对最终用户的体验产生不利影响.有关更多帮助,请查看 https://xhr.spec.whatwg.org/.",在此代码上:
I see this error: "[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", on this code:
var request;
if(window.XMLHttpRequest){
request = new XMLHttpRequest();
}else{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
request.open('GET', 'http://www.mywebsite.com', false);
request.send();
我应该用什么来替换指令,因为它们已被弃用?
What should I replace the instructions with because they are deprecated?
推荐答案
你只需要改变
request.open('GET', 'http://www.mywebsite.com', false);
到
request.open('GET', 'http://www.mywebsite.com', true);
这篇关于弃用同步 XMLHttpRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文