pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <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="rnd7tr5" 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="drpnvb7" 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="dbbzljn" id='AFA0X'><tfoot id='AFA0X'></tfoot><dl id='AFA0X'><fieldset id='AFA0X'></fieldset></dl></div>

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

                            主站蜘蛛池模板: 洁净棚-洁净工作棚-无菌室-净化工程公司_北京卫护科技有限公司 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 国产频谱分析仪-国产网络分析仪-上海坚融实业有限公司 | 大_小鼠elisa试剂盒-植物_人Elisa试剂盒-PCR荧光定量试剂盒-上海一研生物科技有限公司 | 西安标准厂房_陕西工业厂房_西咸新区独栋厂房_长信科技产业园官方网站 | 铝机箱_铝外壳加工_铝外壳厂家_CNC散热器加工-惠州市铂源五金制品有限公司 | 胶原检测试剂盒,弹性蛋白检测试剂盒,类克ELISA试剂盒,阿达木单抗ELISA试剂盒-北京群晓科苑生物技术有限公司 | DAIKIN电磁阀-意大利ATOS电磁阀-上海乾拓贸易有限公司 | 宜兴紫砂壶知识分享 - 宜兴壶人 医用空气消毒机-医用管路消毒机-工作服消毒柜-成都三康王 | 苏州防水公司_厂房屋面外墙防水_地下室卫生间防水堵漏-苏州伊诺尔防水工程有限公司 | 净化车间_洁净厂房_净化公司_净化厂房_无尘室工程_洁净工程装修|改造|施工-深圳净化公司 | 洗瓶机厂家-酒瓶玻璃瓶冲瓶机-瓶子烘干机-封口旋盖压盖打塞机_青州惠联灌装机械 | 昆山新莱洁净应用材料股份有限公司-卫生级蝶阀,无菌取样阀,不锈钢隔膜阀,换向阀,离心泵 | 上海洗地机-洗地机厂家-全自动洗地机-手推式洗地机-上海滢皓洗地机 | 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 【铜排折弯机,钢丝折弯成型机,汽车发泡钢丝折弯机,线材折弯机厂家,线材成型机,铁线折弯机】贝朗折弯机厂家_东莞市贝朗自动化设备有限公司 | 炒货机-炒菜机-炒酱机-炒米机@霍氏机械 | 手表腕表维修保养鉴定售后服务中心网点 - 名表维修保养 | 地磅-地秤-江阴/无锡地磅-江阴天亿计量设备有限公司_ | 中国品牌排名投票_十大品牌榜单_中国著名品牌【中国品牌榜】 | 大鼠骨髓内皮祖细胞-小鼠神经元-无锡欣润生物科技有限公司 | 上海办公室装修_上海店铺装修公司_厂房装潢设计_办公室装修 | 热风机_工业热风机生产厂家上海冠顶公司提供专业热风机图片价格实惠 | 合肥钣金加工-安徽激光切割加工-机箱机柜加工厂家-合肥通快 | 电磁流量计厂家_涡街流量计厂家_热式气体流量计-青天伟业仪器仪表有限公司 | 超细粉碎机|超微气流磨|气流分级机|粉体改性设备|超微粉碎设备-山东埃尔派粉碎机厂家 | 英国雷迪地下管线探测仪-雷迪RD8100管线仪-多功能数字听漏仪-北京迪瑞进创科技有限公司 | 网站优化公司_SEO优化_北京关键词百度快速排名-智恒博网络 | 荣事达手推洗地机_洗地机厂家_驾驶式扫地机_工业清洁设备 | 心得体会网_心得体会格式范文模板 | 云阳人才网_云阳招聘网_云阳人才市场_云阳人事人才网_云阳人家招聘网_云阳最新招聘信息 | 首页-瓜尔胶系列-化工单体系列-油田压裂助剂-瓜尔胶厂家-山东广浦生物科技有限公司 | 深圳网站建设-高端企业网站开发-定制网页设计制作公司 | 煤矿人员精确定位系统_矿用无线通信系统_煤矿广播系统 | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | 制氮设备-变压吸附制氮设备-制氧设备-杭州聚贤气体设备制造有限公司 | 工业雾炮机_超细雾炮_远程抑尘射雾器-世纪润德环保设备 | 呼末二氧化碳|ETCO2模块采样管_气体干燥管_气体过滤器-湖南纳雄医疗器械有限公司 | 上海电子秤厂家,电子秤厂家价格,上海吊秤厂家,吊秤供应价格-上海佳宜电子科技有限公司 | SDI车窗夹力测试仪-KEMKRAFT方向盘测试仪-上海爱泽工业设备有限公司 | 激光内雕_led玻璃_发光玻璃_内雕玻璃_导光玻璃-石家庄明晨三维科技有限公司 激光内雕-内雕玻璃-发光玻璃 |