2015-04-07 42 views
1
  • 我工作的ExtJS的框架..
    • 我對ExtJS的運行的應用程序..
    • 每當我打開瀏覽器應用程序...我看到以下 警告我的控制檯...

在主線程同步的XMLHttpRequest是因爲它的不利影響已棄用s到最終用戶的體驗。如需更多幫助,請http://xhr.spec.whatwg.org/在主線程同步的XMLHttpRequest已被棄用

  • 你們可以告訴我怎麼刪除..
  • 當我點擊它需要EXT-所有調試-W-comments.js文件警告
  • 並指向以下部分代碼...

    嘗試xhr.open('GET',noCacheUrl,false); xhr.send(null); (e){ isCrossOriginRestricted = true; }

  • 你們可以告訴我如何防止它發生......

  • 提供下面我的代碼在該文件中

    /** * 加載腳本文件,支持異步和同步方法 * @private */ loadScriptFile:function(url,onLoad,onError,scope,synchronous)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; 
         } 
        }, 
    
+1

'xhr.open('GET',noCacheUrl,false);'刪除'false'。但是,你必須將'try-catch'語句下的所有內容移動到像這樣的'xhr.addEventListener('load',function(){'... code ...'})''的事件處理程序中。 – Xufox

+0

@xufox它令人困惑,你可以在下面的代碼中更新代碼https://jsfiddle.net/e1hfjue1/ –

+0

它只發生在你使用動態加載時。這不是一個真正的問題。 –

回答

0

這個警告只顯示在Chrome中ExtJS的開發環境。一旦應用程序使用sencha cmd構建,警告就不會再顯示。正如@Evan指出的那樣,警告看起來很溫和,你不應該擔心。

有警告的事實不應該成爲問題,因爲它永遠不會顯示在已部署的應用程序中。如果您還沒有使用sencha cmd,將它集成到開發週期中是絕對值得的。

我知道這不是問題的直接答案。我自己,我想知道是否有可能擺脫這個警告。

+0

感謝您的回覆...是否有演示,我可以看看哪些幫助我們更好地瞭解,,, –

+0

對於sencha cmd,演示很簡單:下載它,'sencha生成應用程序,然後'sencha應用程序構建',並且您有一個演示應用程序。 –

+0

你可以分享工作簡單,難以理解的小提琴:( –

相關問題