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

<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="tnvxzdh" 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>

        如何創建 XMLHttpRequest 包裝器/代理?

        How can I create a XMLHttpRequest wrapper/proxy?(如何創建 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="ptffhhr" 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>
                  本文介紹了如何創建 XMLHttpRequest 包裝器/代理?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  想到的這些方法,各有什么優缺點?

                  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);
                  }
                  

                  推薦答案

                  根據 JS 引擎,方法 1 會產生相當大的開銷,因為每當實例化 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)

                  這篇關于如何創建 XMLHttpRequest 包裝器/代理?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                    <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="3rzzhx7" 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>
                            主站蜘蛛池模板: 乐泰胶水_loctite_乐泰胶_汉高乐泰授权(中国)总代理-鑫华良供应链 | 越南专线物流_东莞国际物流_东南亚专线物流_行通物流 | 河南砖机首页-全自动液压免烧砖机,小型砌块水泥砖机厂家[十年老厂] | 紫外荧光硫分析仪-硫含量分析仪-红外光度测定仪-泰州美旭仪器 | 涂层测厚仪_漆膜仪_光学透过率仪_十大创新厂家-果欧电子科技公司 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 | 土壤墒情监测站_土壤墒情监测仪_土壤墒情监测系统_管式土壤墒情站-山东风途物联网 | 冷却塔降噪隔音_冷却塔噪声治理_冷却塔噪音处理厂家-广东康明冷却塔降噪厂家 | 步进_伺服_行星减速机,微型直流电机,大功率直流电机-淄博冠意传动机械 | WF2户外三防照明配电箱-BXD8050防爆防腐配电箱-浙江沃川防爆电气有限公司 | 语料库-提供经典范文,文案句子,常用文书,您的写作得力助手 | 南京技嘉环保科技有限公司-杀菌除臭剂|污水|垃圾|厕所|橡胶厂|化工厂|铸造厂除臭剂 | 东莞注册公司-代办营业执照-东莞公司注册代理记账-极刻财税 | 开云(中国)Kaiyun·官方网站 - 登录入口 | Jaeaiot捷易科技-英伟达AI显卡模组/GPU整机服务器供应商 | 领先的大模型技术与应用公司-中关村科金 | 螺钉式热电偶_便携式温度传感器_压簧式热电偶|无锡联泰仪表有限公司|首页 | 同步带轮_同步带_同步轮_iHF合发齿轮厂家-深圳市合发齿轮机械有限公司 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | 切铝机-数控切割机-型材切割机-铝型材切割机-【昆山邓氏精密机械有限公司】 | 锂电混合机-新能源混合机-正极材料混料机-高镍,三元材料混料机-负极,包覆混合机-贝尔专业混合混料搅拌机械系统设备厂家 | 采暖炉_取暖炉_生物质颗粒锅炉_颗粒壁炉_厂家加盟批发_烟台蓝澳采暖设备有限公司 | 纯水电导率测定仪-万用气体检测仪-低钠测定仪-米沃奇科技(北京)有限公司www.milwaukeeinst.cn 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 手术室净化装修-手术室净化工程公司-华锐手术室净化厂家 | 深圳诚暄fpc首页-柔性线路板,fpc柔性线路板打样生产厂家 | 专业的压球机生产线及解决方案厂家-河南腾达机械厂 | 珠宝展柜-玻璃精品展柜-首饰珠宝展示柜定制-鸿钛展柜厂家 | 厌氧工作站-通用型厌氧工作站-上海胜秋科学仪器有限公司 | 污泥烘干机-低温干化机-工业污泥烘干设备厂家-焦作市真节能环保设备科技有限公司 | 薪动-人力资源公司-灵活用工薪资代发-费用结算-残保金优化-北京秒付科技有限公司 | CE认证_产品欧盟ROHS-REACH检测机构-商通检测 | 深圳诚暄fpc首页-柔性线路板,fpc柔性线路板打样生产厂家 | 光纤测温-荧光光纤测温系统-福州华光天锐光电科技有限公司 | 高硼硅玻璃|水位计玻璃板|光学三棱镜-邯郸奥维玻璃科技有限公司 高温高压釜(氢化反应釜)百科 | 焦作网 WWW.JZRB.COM| 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 深圳市八百通智能技术有限公司官方网站 | 昆明化妆培训-纹绣美甲-美容美牙培训-昆明博澜培训学校 | 电动百叶窗,开窗器,电动遮阳百叶,电动开窗机生产厂家-徐州鑫友工控科技发展有限公司 | 首页-瓜尔胶系列-化工单体系列-油田压裂助剂-瓜尔胶厂家-山东广浦生物科技有限公司 | 开云(中国)Kaiyun·官方网站 - 登录入口| 电动垃圾车,垃圾清运车-江苏速利达机车有限公司|