所以我一直在我的控制台app.js:159 [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/.
中得到这个
我一直在寻找一种方法将JSON解析为一个url并遇到这个代码块,这似乎是在抛出错误。
function readJSON(file) {
const request = new XMLHttpRequest();
request.open('GET', file, false);
request.send(null);
if (request.status == 200)
return request.responseText;
};
经过一些研究后,我遇到了设置async = true
,但没有任何运气。
此外,作为旁注,我的应用程序使用HTML Geolocation,它不能在GitHub页面上工作,但在本地工作正常。有什么想法吗?谢谢
将false切换为true。语法:XMLHttpRequest.open(method,url,async)
request.open('GET', file, true);
request.onload = function() {
//response is available as request.response here
}