[英]Synchronous XMLHttpRequest on the main thread is deprecated
不贊成在主線程上使用同步XMLHttpRequest,因為它會對最終用戶的體驗產生不利影響。 如需更多幫助,請訪問http://xhr.spec.whatwg.org/
並指向代碼的以下部分...
嘗試{xhr.open('GET',noCacheUrl,false); xhr.send(NULL); } catch(e){isCrossOriginRestricted = true; }
你們能告訴我如何防止它發生嗎?
在該文件中提供我的代碼
/ ** *加載腳本文件,同時支持異步方法和同步方法* @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; } },
僅在ExtJs開發環境中的Chrome中顯示此警告。 使用sencha cmd
構建應用程序后,警告不再顯示。 正如@Evan指出的那樣,警告看起來是無害的,您不必擔心。
存在警告的事實不應成為問題,因為它永遠不會在已部署的應用程序中顯示。 如果您尚未使用sencha cmd,那么絕對值得將其集成到您的開發周期中。
我知道這不是問題的直接答案。 我自己,我想知道是否有可能完全消除這一警告。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.