[英]Synchronous XMLHttpRequest on the main thread is deprecated
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. 不赞成在主线程上使用同步XMLHttpRequest,因为它会对最终用户的体验产生不利影响。 For more help, check http://xhr.spec.whatwg.org/
如需更多帮助,请访问http://xhr.spec.whatwg.org/
and points to the following part of code... 并指向代码的以下部分...
try { xhr.open('GET', noCacheUrl, false); 尝试{xhr.open('GET',noCacheUrl,false); xhr.send(null);
xhr.send(NULL); } catch (e) { isCrossOriginRestricted = true;
} catch(e){isCrossOriginRestricted = true; }
}
can you guys tell me how to prevent it from happening... 你们能告诉我如何防止它发生吗?
providing my code below in that file 在该文件中提供我的代码
/** * Load a script file, supports both asynchronous and synchronous approaches * @private */ loadScriptFile: function(url, onLoad, onError, scope, synchronous) { if (isFileLoaded[url]) { return Loader; / ** *加载脚本文件,同时支持异步方法和同步方法* @private * / loadScriptFile:function(url,onLoad,onError,作用域,同步){if(isFileLoaded [url]){return Loader; }
}
var config = Loader.getConfig(), noCacheUrl = url + (config.disableCaching ? ('?' + config.disableCachingParam + '=' + Ext.Date.now()) : ''), isCrossOriginRestricted = false, xhr, status, onScriptError, debugSourceURL = ""; scope = scope || Loader; Loader.isLoading = true; if (!synchronous) { onScriptError = function() { }; scriptElements[url] = Loader.injectScriptElement(noCacheUrl, onLoad, onScriptError, scope); } else { if (typeof XMLHttpRequest != 'undefined') { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } try { xhr.open('GET', noCacheUrl, false); xhr.send(null); } catch (e) { isCrossOriginRestricted = true; } status = (xhr.status === 1223) ? 204 : (xhr.status === 0 && (self.location || {}).protocol == 'file:') ? 200 : xhr.status; isCrossOriginRestricted = isCrossOriginRestricted || (status === 0); if (isCrossOriginRestricted ) { } else if ((status >= 200 && status < 300) || (status === 304) ) { // Debugger friendly, file names are still shown even though they're eval'ed code // Breakpoints work on both Firebug and Chrome's Web Inspector if (!Ext.isIE) { debugSourceURL = "\\n//@ sourceURL=" + url; } Ext.globalEval(xhr.responseText + debugSourceURL); onLoad.call(scope); } else { } // Prevent potential IE memory leak xhr = null; } },
This warning is only showing in Chrome in the development environment of ExtJs. 仅在ExtJs开发环境中的Chrome中显示此警告。 Once the application is built with
sencha cmd
, the warning doesn't show anymore. 使用
sencha cmd
构建应用程序后,警告不再显示。 As @Evan pointed out the warning looks benign, and you should not have to worry about it. 正如@Evan指出的那样,警告看起来是无害的,您不必担心。
The fact that there is a warning should not be an issue, since it will never show in a deployed application. 存在警告的事实不应成为问题,因为它永远不会在已部署的应用程序中显示。 If you do not yet use sencha cmd, it is definitely worth to integrate it in your development cycle.
如果您尚未使用sencha cmd,那么绝对值得将其集成到您的开发周期中。
I know it is not a direct answer to the question. 我知道这不是问题的直接答案。 Myself, I wonder if it is possible to get rid of this warning at all.
我自己,我想知道是否有可能完全消除这一警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.