久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='qINF4'><style id='qINF4'><dir id='qINF4'><q id='qINF4'></q></dir></style></legend>
  • <i id='qINF4'><tr id='qINF4'><dt id='qINF4'><q id='qINF4'><span id='qINF4'><b id='qINF4'><form id='qINF4'><ins id='qINF4'></ins><ul id='qINF4'></ul><sub id='qINF4'></sub></form><legend id='qINF4'></legend><bdo id='qINF4'><pre id='qINF4'><center id='qINF4'></center></pre></bdo></b><th id='qINF4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qINF4'><tfoot id='qINF4'></tfoot><dl id='qINF4'><fieldset id='qINF4'></fieldset></dl></div>

    <tfoot id='qINF4'></tfoot>

    1. <small id='qINF4'></small><noframes id='qINF4'>

        <bdo id='qINF4'></bdo><ul id='qINF4'></ul>

        不推薦使用同步 XMLHttpRequest

        Synchronous XMLHttpRequest deprecated(不推薦使用同步 XMLHttpRequest)
      1. <i id='m5HJL'><tr id='m5HJL'><dt id='m5HJL'><q id='m5HJL'><span id='m5HJL'><b id='m5HJL'><form id='m5HJL'><ins id='m5HJL'></ins><ul id='m5HJL'></ul><sub id='m5HJL'></sub></form><legend id='m5HJL'></legend><bdo id='m5HJL'><pre id='m5HJL'><center id='m5HJL'></center></pre></bdo></b><th id='m5HJL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='m5HJL'><tfoot id='m5HJL'></tfoot><dl id='m5HJL'><fieldset id='m5HJL'></fieldset></dl></div>

          <bdo id='m5HJL'></bdo><ul id='m5HJL'></ul>

            <small id='m5HJL'></small><noframes id='m5HJL'>

                  <tbody id='m5HJL'></tbody>
                <legend id='m5HJL'><style id='m5HJL'><dir id='m5HJL'><q id='m5HJL'></q></dir></style></legend>
                  <tfoot id='m5HJL'></tfoot>
                  本文介紹了不推薦使用同步 XMLHttpRequest的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  今天,由于擴展程序的一些問題,我不得不重新啟動瀏覽器.當我重新啟動它時,我發現我的瀏覽器(Chromium)自動更新到不再允許同步 AJAX 請求的新版本.引用:

                  Today, I had to restart my browser due to some issue with an extension. What I found when I restarted it, was that my browser (Chromium) automatically updated to a new version that doesn't allow synchronous AJAX-requests anymore. Quote:

                  主線程上的同步 XMLHttpRequest 已被棄用,因為其對最終用戶體驗的不利影響.如需更多幫助,檢查 http://xhr.spec.whatwg.org/.

                  Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

                  我需要同步 AJAX 請求才能讓我的 node.js 應用程序工作,因為它們通過使用 fopen 的服務器從磁盤存儲和加載數據.我發現這是一種非常簡單有效的做事方式,在創建小愛好項目和編輯器時非常方便......有沒有辦法在 Chrome/Chromium 中重新啟用同步 XMLHttpRequests?

                  I need synchronous AJAX-requests for my node.js applications to work though, as they store and load data from disk through a server utilizing fopen. I found this to be a very simplistic and effective way of doing things, very handy in the creation of little hobby projects and editors... Is there a way to re-enable synchronous XMLHttpRequests in Chrome/Chromium?

                  推薦答案

                  此答案已編輯.

                  簡答:他們不想在 main 線程上同步.

                  Short answer: They don't want sync on the main thread.

                  對于支持線程/網絡工作者的新瀏覽器來說,解決方案很簡單:

                  The solution is simple for new browsers that support threads/web workers:

                  var foo = new Worker("scriptWithSyncRequests.js")
                  

                  DOM 和全局變量都不會在 worker 中可見,但封裝多個同步請求將非常容易.

                  Neither DOM nor global vairables aren't going to be visible within a worker but encapsulation of multiple synchronous requests is going to be really easy.

                  替代解決方案是切換到異步,但使用瀏覽器 localStorage 和 JSON.stringify 作為媒介.如果你允許做一些 IO,你也許可以模擬 localStorage.http://caniuse.com/#search=localstorage

                  Alternative solution is to switch to async but to use browser localStorage along with JSON.stringify as a medium. You might be able to mock localStorage if you allowed to do some IO. http://caniuse.com/#search=localstorage

                  只是為了好玩,如果我們想限制自己只使用同步,還有其他的技巧:

                  Just for fun, there are alternative hacks if we want to restrict our self using only sync:

                  使用 setTimeout 很誘人,因為人們可能認為它是一種將同步請求封裝在一起的好方法.可悲的是,有一個問題.javascript 中的異步并不意味著它可以在自己的線程中運行.Async 可能會推遲調用,等待其他人完成.幸運的是,隧道盡頭有光,因為您很可能可以使用 xhttp.timeout 和 xhttp.ontimeout 來恢復.請參閱 超時 XMLHttpRequest這意味著我們可以實現微型版本的調度程序來處理失敗的請求并分配時間重試或報告錯誤.

                  It is tempting to use setTimeout because one might think it is a good way to encapsulate synchronous requests together. Sadly, there is a gotcha. Async in javascript doesn't mean it gets to run in its own thread. Async is likely postponing the call, waiting for others to finish. Lucky for us there is light at the end of the tunnel because it is likely you can use xhttp.timeout along with xhttp.ontimeout to recover. See Timeout XMLHttpRequest This means we can implement tiny version of a schedular that handles failed request and allocates time to try again or report error.

                  // The basic idea.
                  function runSchedular(s)
                  {
                      setTimeout(function() {
                          if (s.ptr < callQueue.length) {
                              // Handles rescheduling if needed by pushing the que.
                              // Remember to set time for xhttp.timeout.
                              // Use xhttp.ontimeout to set default return value for failure.
                              // The pushed function might do something like: (in pesudo)
                              // if !d1
                              // d1 = get(http...?query);
                              // if !d2
                              // d2 = get(http...?query);
                              // if (!d1) {pushQue tryAgainLater}
                              // if (!d2) {pushQue tryAgainLater}
                              // if (d1 && d2) {pushQue handleData}
                              s = s.callQueue[s.ptr++](s);
                          } else {
                              // Clear the que when there is nothing more to do.
                              s.ptr = 0;
                              s.callQueue = [];
                              // You could implement an idle counter and increase this value to free
                              // CPU time.
                              s.t = 200;
                          }
                          runSchedular(s);
                      }, s.t);
                  }
                  

                  這篇關于不推薦使用同步 XMLHttpRequest的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                1. <legend id='Peyya'><style id='Peyya'><dir id='Peyya'><q id='Peyya'></q></dir></style></legend><tfoot id='Peyya'></tfoot>
                  <i id='Peyya'><tr id='Peyya'><dt id='Peyya'><q id='Peyya'><span id='Peyya'><b id='Peyya'><form id='Peyya'><ins id='Peyya'></ins><ul id='Peyya'></ul><sub id='Peyya'></sub></form><legend id='Peyya'></legend><bdo id='Peyya'><pre id='Peyya'><center id='Peyya'></center></pre></bdo></b><th id='Peyya'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Peyya'><tfoot id='Peyya'></tfoot><dl id='Peyya'><fieldset id='Peyya'></fieldset></dl></div>

                    <tbody id='Peyya'></tbody>

                  1. <small id='Peyya'></small><noframes id='Peyya'>

                            <bdo id='Peyya'></bdo><ul id='Peyya'></ul>
                          • 主站蜘蛛池模板: 国产精品无码久久久久 | 日日日日操| 久久91精品国产一区二区 | 久久综合伊人 | 日韩在线视频免费观看 | 91精品久久久 | 色天堂影院 | 亚洲国产精品一区二区第一页 | 亚洲美女天堂网 | 视频一区二区在线观看 | 男人天堂久久久 | 国产精品久久久久久久久久久久久 | 一级毛片在线播放 | 国产一区二区三区精品久久久 | 青青艹在线视频 | 中文字幕av在线 | 国产无人区一区二区三区 | 日韩一二三区视频 | 色婷婷av久久久久久久 | 免费激情 | 日韩欧美一级片 | 亚洲综合在 | 国产成人久久精品 | 免费成人在线网站 | 精久久久 | 国产成人精品久久二区二区91 | 久久99精品久久久久 | 四虎最新视频 | 一区二区三区免费观看 | 成人久久网| 日韩免费视频 | 精品久久久久久久久久久 | 国产成人精品一区二区三区在线 | 色综合久 | 欧美黑人激情 | 青青草网 | 91免费视频观看 | 91久久国产综合久久91精品网站 | 国产美女黄色片 | 国产高清精品一区二区三区 | 亚州国产 |