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

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

        <tfoot id='wUjyc'></tfoot>
          <bdo id='wUjyc'></bdo><ul id='wUjyc'></ul>
      1. <legend id='wUjyc'><style id='wUjyc'><dir id='wUjyc'><q id='wUjyc'></q></dir></style></legend>
      2. <small id='wUjyc'></small><noframes id='wUjyc'>

        Javascript 同步 XMLHttpRequest 的替代方案(在 Safari 中

        Alternatives for Javascript Synchronous XMLHttpRequest (as timing out in Safari)(Javascript 同步 XMLHttpRequest 的替代方案(在 Safari 中超時))
        1. <legend id='4AxtW'><style id='4AxtW'><dir id='4AxtW'><q id='4AxtW'></q></dir></style></legend>
            <tbody id='4AxtW'></tbody>

            <small id='4AxtW'></small><noframes id='4AxtW'>

                  <bdo id='4AxtW'></bdo><ul id='4AxtW'></ul>

                  <tfoot id='4AxtW'></tfoot>
                  <i id='4AxtW'><tr id='4AxtW'><dt id='4AxtW'><q id='4AxtW'><span id='4AxtW'><b id='4AxtW'><form id='4AxtW'><ins id='4AxtW'></ins><ul id='4AxtW'></ul><sub id='4AxtW'></sub></form><legend id='4AxtW'></legend><bdo id='4AxtW'><pre id='4AxtW'><center id='4AxtW'></center></pre></bdo></b><th id='4AxtW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4AxtW'><tfoot id='4AxtW'></tfoot><dl id='4AxtW'><fieldset id='4AxtW'></fieldset></dl></div>
                  本文介紹了Javascript 同步 XMLHttpRequest 的替代方案(在 Safari 中超時)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  短版:正在尋找等待異步 XHR 請求的方法或讓同步 XHR 在 Safari 中工作的方法.

                  Short version: Looking for a method to wait for an Asynch XHR request or a way to get Synch XHR working in Safari.

                  更長的版本:我正在開發一個使用混合在一起的各種外部數據源的 Web 服務.我正在使用 Javacript 前端,它可以對我的 PHP 服務器代碼進行 AJAX/XHR 調用.不存在跨站點問題,因為客戶端只向我的服務器請求數據(服務器發出外部數據請求).

                  Much longer version: I'm working on a web service that uses various external data sources mashed together. I am using a Javacript front-end which makes AJAX/XHR calls to my PHP server code. There's no cross-site issues as the client only requests data from my server (the server makes the external data requests).

                  我正在使用同步 XHR 請求,因為在數據顯示在屏幕上之前,我需要對數據進行一些加載后處理(排序、過濾等).

                  I'm using a synchronous XHR request as I have some post-load processing (sorting, filtering, etc) to do on the data before it is presented on screen.

                  這在 IE、FF 和 Opera 上都可以正常工作,但對 Safari 來說似乎是個問題(我還沒有嘗試過 Chrome).

                  This all works fine on IE, FF and Opera, but seems to be a problem to Safari (I haven't tried Chrome yet).

                  在我的 Windows 機器上使用 Firebug for Safari,我可以看到服務器調用 beng,然后在 10 秒以上的時間后失敗.在我的 iPad 上,消息稍微好一些,因為它說:NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous mode.

                  Using Firebug for Safari on my Windows machine I can see the server calling beng made and then it fails after a time above 10 seconds. On my iPad the message is slightly beter as it says: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous mode.

                  一些研究表明 Safari 會在同步模式下 10 秒后超時.似乎有一個超時功能,您可以使用該超時功能來擴展它(Safari 的最大限制為 60 秒).不幸的是,我無法讓它工作.

                  A bit of research indicates that Safari will timeout after 10 seconds in synch mode. There appears to be a timeout function which timeout function you can use to extend this (with a max limit for Safari of 60 seconds). Unfortunately I can't get this to work.

                  我現在想知道人們會建議通過更改客戶端 Javacript 代碼來解決此問題的最佳方法.

                  I'm now wondering what people would suggest as the best way of working around this through changes to the client Javacript code.

                  我正在考慮的兩個選項是 (i) 找到 Safari 瀏覽器將遵守的同步 XHR 超時的工作示例;或 (ii) 對異步 XHR 調用進行某種包裝,以便加載后處理首先等待加載.

                  The two options I'm thinking are (i) find a working example of a synch XHR timeout that Safari browsers will honour; or (ii) having some sort of wrapper around an asynch XHR call so that the post-load processing waits for the load first.

                  我不是一個特別有經驗的 Javascript 黑客,但我已經在這個項目上設置了相當數量.我沒有使用過 JQuery 或任何其他框架,我更愿意使用原始 JS,以避免學習額外的語法.[您可能從我之前的帖子中看到,我過去曾嘗試使用 JQM 和 Spry,但事實證明兩者都是錯誤的選擇,至少在現階段已經被放棄了].

                  I'm not a particulalry experienced Javascript hacker, but I have setup a fair amount on this project. I haven't used JQuery or any other frameworks and would prefer to keep with raw JS just to avoid having to learn the additional syntax. [You may see from my previous posts I tried using JQM and Spry in the past, but both proved to be the wrong choices, at least at this stage and have since been ditched for now].

                  我覺得回調可能是正確的等待異步選項,但我不確定它是如何工作的,或者你將如何編碼.

                  I get the feeling a callback may be the right wait-for-asych option, but I'm not sure how this works or how you would code it.

                  這只是現階段的原型,因此可以接受骯臟的黑客攻擊.一旦我證明了功能,就已經準備好完全重寫.

                  This is just a prototype at this stage, so dirty hacks are acceptable. A full re-write is already on the cards for later on once I have proven functionality.

                  感謝人們對此的想法和建議.

                  Appreciate peoples thoughts and advice on this.

                  問候,皮特.

                  推薦答案

                  通常,您會希望堅持使用異步請求,因為它們是非阻塞的.有了它們,您將需要使用回調 - 或者簡單地說,是一個設置為稍后調用的函數.

                  Generally, you'll want to stick to asynchronous requests, as they're non-blocking. And with them, you'll want to use a callback -- or, simply, a function that is setup to be called later.

                  您可以使用 onreadystatechange 屬性設置回調XMLHttpRequest:

                  You can set the callback with the onreadystatechange property of an XMLHttpRequest:

                  xhr.onreadystatechange = function () {
                      if (xhr.readyState === 4) {   // DONE
                          if (xhr.status === 200) { // OK
                              handleSuccess(xhr);
                          } else {
                              handleError(xhr);
                          }
                      }
                  };
                  

                  正如屬性名所暗示的,它會在readyState的值改變時被調用,其中4的值表示請求已經完成(成功與否).

                  As the property name suggests, it will be called as the value of readyState changes, where a value of 4 means the request has completed (successful or not).

                  然后您將在另一個函數中處理排序、過濾等 - 在本例中為 handleSuccess.

                  You'd then handle your sorting, filtering, etc. within another function -- in this example, handleSuccess.

                  您還可以從使用許多現有庫中的任何一個中受益——例如,jQuery(為此需要 1.6 或更高版本片段):

                  You can also benefit from using any of a number of existing libraries -- e.g., jQuery (1.6 or later for this snippet):

                  $.get('/web/service/request')
                      .done(function (result) {
                          // sorting, filtering, etc
                      })
                      .fail(function (xhr) {
                          // error notification, etc.
                      });
                  

                  這篇關于Javascript 同步 XMLHttpRequest 的替代方案(在 Safari 中超時)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  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))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                • <tfoot id='AFA0X'></tfoot>

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

                      <legend id='AFA0X'><style id='AFA0X'><dir id='AFA0X'><q id='AFA0X'></q></dir></style></legend>
                      • <bdo id='AFA0X'></bdo><ul id='AFA0X'></ul>

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

                              <tbody id='AFA0X'></tbody>

                            主站蜘蛛池模板: 一级高清免费毛片 | 欧美日韩不卡合集视频 | 久久精彩 | 国产精品久久久久久久久久久免费看 | 国产一区日韩在线 | 在线视频一区二区三区 | 免费人成在线观看网站 | 中文在线一区二区 | 日韩精品一区二区三区 | 毛片一区二区 | 亚洲精品成人 | 中文字幕在线一区 | 国产免费一区二区 | 国产在线视频一区二区 | 91精品久久久 | 欧美综合一区二区三区 | 午夜欧美一区二区三区在线播放 | 日韩欧美在线一区 | 中文字幕亚洲精品 | 亚洲精品一区二区三区蜜桃久 | 亚洲视频一区在线观看 | 亚洲欧美激情网 | 欧美一二三| 日韩视频免费 | av大片在线观看 | 2021天天干夜夜爽 | 精品国产乱码一区二区三区a | 91色网站| 中文字幕成人av | 国产精品99久久久久久www | 国产大毛片 | 桃色五月| 亚洲女人天堂成人av在线 | 91精品国产高清一区二区三区 | 99re在线视频 | 亚洲成人免费在线 | 殴美黄色录像 | 美女在线观看国产 | 日韩一区二区三区av | 久久久亚洲精品视频 | 亚洲欧洲视频 |