简体   繁体   English

不赞成在主线程上使用同步XMLHttpRequest

[英]Synchronous XMLHttpRequest on the main thread is deprecated

  • I am working on extjs framework.. 我正在研究extjs框架。
    • i have an application running on extjs.. 我有一个在extjs上运行的应用程序。
    • whenever i open the application in the browser...i see the following warnings in my console... 每当我在浏览器中打开应用程序...我在控制台中看到以下警告...

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/

  • can you guys tell me how to remove it.. 你们能告诉我如何删除它吗..
  • when i click the warning it takes to ext-all-debug-w-comments.js file 当我单击警告时,它将带到ext-all-debug-w-comments.js文件
  • 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.

相关问题 不推荐在主线程上使用同步XMLHttpRequest - Synchronous XMLHttpRequest on the main thread is deprecated 不推荐使用主线程上的Firebase同步XMLHttpRequest - Firebase Synchronous XMLHttpRequest on the main thread is deprecated $.get 不是 function,不推荐使用主线程上的同步 XMLHttpRequest - $.get is not a function, Synchronous XMLHttpRequest on the main thread is deprecated XMLHTTPRequest错误:不建议在主线程上使用同步XMLHttpRequest…(SoundCloud API) - XMLHTTPRequest Error: Synchronous XMLHttpRequest on the main thread is deprecated … (SoundCloud API) 使用jQuery加载外部javascript并禁止“不建议在主线程上使用同步XMLHttpRequest…” - Loading external javascript with jQuery and suppress “Synchronous XMLHttpRequest on the main thread is deprecated…” jQuery load()错误:不推荐使用主线程上的同步XMLHttpRequest - jQuery load() error : Synchronous XMLHttpRequest on the main thread is deprecated 向后移动会导致错误:““不赞成在主线程上使用同步XMLHttpRequest…” - moving backward causes error: "“Synchronous XMLHttpRequest on the main thread is deprecated…” 主线程上的同步 XMLHttpRequest 在嵌入式 Javascript 代码中已弃用 - Synchronous XMLHttpRequest on the main thread is deprecated within embedded Javascript code Angular指令获取“主线程上的同步XMLHttpRequest已弃用” - Angular directive gets “Synchronous XMLHttpRequest on the main thread is deprecated” WordPress + jQuery Mobile-不赞成在主线程上使用同步XMLHttpRequest吗? - WordPress + jQuery Mobile - Synchronous XMLHttpRequest on the main thread is deprecated?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM