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

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

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

        如何創(chuàng)建 XMLHttpRequest 包裝器/代理?

        How can I create a XMLHttpRequest wrapper/proxy?(如何創(chuàng)建 XMLHttpRequest 包裝器/代理?)

          <tbody id='FhGv0'></tbody>
        • <small id='FhGv0'></small><noframes id='FhGv0'>

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

                  <tfoot id='FhGv0'></tfoot>
                  本文介紹了如何創(chuàng)建 XMLHttpRequest 包裝器/代理?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  想到的這些方法,各有什么優(yōu)缺點?

                  These methods that come to mind, what are the pros and cons of each?

                  方法一:增強原生實例

                  var _XMLHttpRequest = XMLHttpRequest;
                  XMLHttpRequest = function() {
                      var xhr = new _XMLHttpRequest();
                  
                      // augment/wrap/modify here
                      var _open = xhr.open;
                      xhr.open = function() {
                          // custom stuff
                          return _open.apply(this, arguments);
                      }
                  
                      return xhr;
                  }
                  

                  方法2:子類"原生XMLHttpRequest

                  Method 2: Sub-"class" native XMLHttpRequest

                  var _XMLHttpRequest = XMLHttpRequest;
                  XMLHttpRequest = function() {
                      // definePropertys here etc
                  }
                  
                  XMLHttpRequest.prototype = new _XMLHttpRequest());
                  // OR
                  XMLHttpRequest.prototype = Object.create(_XMLHttpRequest);
                  
                  // custom wrapped methods on prototype here
                  XMLHttpRequest.prototype.open = function() {
                      // custom stuff
                      return _XMLHttpRequest.prototype.open.apply(this, arguments);
                  }
                  

                  方法三:完全代理原生 XMLHttpRequest

                  Method 3: Full proxy to native XMLHttpRequest

                  var _XMLHttpRequest = XMLHttpRequest;
                  XMLHttpRequest = function() {
                      this.xhr = new _XMLHttpRequest();
                  }
                  
                  // proxy ALL methods/properties
                  XMLHttpRequest.prototype.open = function() {
                      // custom stuff
                      return this.xhr.open.apply(this.xhr, arguments);
                  }
                  

                  推薦答案

                  根據(jù) JS 引擎,方法 1 會產(chǎn)生相當(dāng)大的開銷,因為每當(dāng)實例化 XHR 時都會重新定義 xhr.open.

                  Depending on the JS engine, method 1 produces considerable overhead, since xhr.open is redefined whenever XHR is instantiated.

                  方法 2 讓我想為什么首先需要 new _XMLHttpRequest"?有輕微副作用的感覺,但似乎效果很好.

                  Method 2 makes me think "why would you need the new _XMLHttpRequest in the first place"? There's a minor feeling of undesired side effects, but it appears to work just fine.

                  方法 3:簡單、老派,但不會立即奏效.(考慮讀取屬性)

                  Method 3: simple, old-school, but it won't work straight-away. (Think about reading properties)

                  一般來說,我個人不太愿意覆蓋瀏覽器對象,所以這對所有三種方法來說都是一個很大的缺點.最好使用其他變量,例如 ProxyXHR(只是我的 2 美分)

                  In general, I'm personally reluctant when it comes to overwriting browser objects, so that would be a big con to all three methods. Better use some other variable like ProxyXHR (just my 2 cents)

                  這篇關(guān)于如何創(chuàng)建 XMLHttpRequest 包裝器/代理?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                  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標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  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 部分內(nèi)容)
                    <tbody id='AF7V5'></tbody>
                  <i id='AF7V5'><tr id='AF7V5'><dt id='AF7V5'><q id='AF7V5'><span id='AF7V5'><b id='AF7V5'><form id='AF7V5'><ins id='AF7V5'></ins><ul id='AF7V5'></ul><sub id='AF7V5'></sub></form><legend id='AF7V5'></legend><bdo id='AF7V5'><pre id='AF7V5'><center id='AF7V5'></center></pre></bdo></b><th id='AF7V5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AF7V5'><tfoot id='AF7V5'></tfoot><dl id='AF7V5'><fieldset id='AF7V5'></fieldset></dl></div>
                    <bdo id='AF7V5'></bdo><ul id='AF7V5'></ul>

                      • <small id='AF7V5'></small><noframes id='AF7V5'>

                      • <legend id='AF7V5'><style id='AF7V5'><dir id='AF7V5'><q id='AF7V5'></q></dir></style></legend>
                      • <tfoot id='AF7V5'></tfoot>
                            主站蜘蛛池模板: 欧美成人黄色小说 | 99久久国产综合精品麻豆 | av在线天堂网 | 中文字幕亚洲一区二区三区 | 自拍偷拍一区二区三区 | www.亚洲视频.com | aaa综合国产 | 亚洲一区在线观看视频 | 亚洲视频在线观看 | 国产我和子的乱视频网站 | 国产aⅴ爽av久久久久久久 | 久草青青草 | 乳色吐息在线观看 | 亚洲最大成人综合 | 全免费a级毛片免费看视频免费下 | 在线午夜电影 | 成人免费视频观看视频 | 国产精品一区一区三区 | 欧美日韩久久久 | 一二三四在线视频观看社区 | 中文字幕色站 | 国产不卡一区 | 91在线视频国产 | 国产成人在线免费 | 一区二区三区免费在线观看 | 99精品在线免费观看 | 亚洲福利一区二区 | 欧美日韩国产一区二区三区不卡 | 亚洲国产精品久久 | 国产精品一区二区视频 | 国产精品美女久久久久aⅴ国产馆 | 成人做爰www免费看视频网站 | 一区二区三区四区五区在线视频 | 日韩在线视频一区 | 激情自拍偷拍 | 国产成人免费视频网站视频社区 | www.99热这里只有精品 | 欧洲精品在线观看 | 成人av播放| 日韩精品免费 | 日韩一区二区av |