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

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

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

    1. <tfoot id='NdJhG'></tfoot>

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

        <legend id='NdJhG'><style id='NdJhG'><dir id='NdJhG'><q id='NdJhG'></q></dir></style></legend>

        為什么我們在 XMLHttpRequest 中寫 send() 之前要寫

        Why do we write onload() function before we write send() in XMLHttpRequest(為什么我們在 XMLHttpRequest 中寫 send() 之前要寫 onload() 函數)
      1. <small id='UgXeq'></small><noframes id='UgXeq'>

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

              <tfoot id='UgXeq'></tfoot>

                    <tbody id='UgXeq'></tbody>
                  本文介紹了為什么我們在 XMLHttpRequest 中寫 send() 之前要寫 onload() 函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 XMLHttpRequest 的新手.我不明白為什么我們要在 send() 函數之前編寫 onload() 函數.onload() 函數處理我們收到的響應,然后 send() 函數向服務器發送請求.所以根據我的理解,onload() 必須在 send() 函數之后編寫.有人可以幫助理解這一點.

                  I am new to XMLHttpRequest. I dont understand why do we write onload() function before send() function. onload() function process the response what we receive and send() function sends a request to server. So onload() has to be written after send() function as per my understanding. Can somebody help to understand this.

                  var xmlhttp = new XMLHttpRequest(),
                    method = 'GET',
                    url = 'https://developer.mozilla.org/';
                  
                  xmlhttp.open(method, url, true);
                  xmlhttp.onload = function () {
                    // Do something with the retrieved data
                  };
                  xmlhttp.send();
                  

                  推薦答案

                  我不明白為什么我們要在 send() 函數之前寫 onload() 函數.

                  I dont understand why do we write onload() function before send() function.

                  以便在發送請求之前加載處理程序,因為發送請求將導致調用處理程序(如果成功).

                  So that the load handler is in place before the request is sent, since sending the request will result in calling the handler (if successful).

                  onload() 函數處理我們收到的響應,send() 函數向服務器發送請求.所以根據我的理解,onload() 必須寫在 send() 函數之后.

                  onload() function process the response what we receive and send() function sends a request to server. So onload() has to be written after send() function as per my understanding.

                  它在 send 被調用(由 XHR 基礎架構)(或可能在其期間)之后被調用.當您將它分配給 onload 時,您并不是在 調用 它.您只是定義它,以便當 XHR 需要調用它時它就在那里.

                  It's called after send is called (by the XHR infrastructure) (or potentially during). When you assign it to onload, you're not calling it. You're just defining it so that it's there when XHR needs to call it.

                  會發生什么:

                  1. 您創建 XHR.
                  2. 您為其 load 事件注冊一個處理程序(在您的情況下,通過將函數分配給 onload).
                  3. 你調用 send.
                  1. You create the XHR.
                  2. You register a handler for its load event (in your case, by assigning a function to onload).
                  3. You call send.
                  1. 瀏覽器啟動(并可能完成)請求

                • 當請求完成時,如果成功,瀏覽器的 XHR 處理會觸發 load 事件.這會查找任何當前注冊的 load 處理程序,并將對這些處理程序的調用(如果有)排隊.這些調用會在主 JavaScript 線程可用于運行它們時立即運行.
                • When the request finishes, if it's successful, the browser's XHR handling triggers the load event. That looks for any currently-registered handlers for load and queues calls to those handlers, if any. Those calls are run as soon as the main JavaScript thread is available to run them.
                • 很多時候,你會以錯誤的方式逃脫懲罰,因為在請求完成時,你已經將 load 處理程序放在那里;但不是總是.load 是一個事件.如果可以立即滿足請求(例如,從緩存中),瀏覽器可以send 期間觸發 load,并查看是否有任何 load 處理程序 調用 send 期間,如果沒有,則不對任何回調的調用進行排隊.稍后當您附加處理程序時,該事件已經被觸發(當沒有附加處理程序時).

                  Very often, you'd get away with doing it the wrong way around because by the time the request completes, you'll have put the load handler there; but not always. load is an event. If the request can be satisfied immediately (for instance, from cache), the browser could fire load during send, and look to see if there's any load handler during the call to send, and if there isn't, not queue a call to any callback. Later when you attach a handler, the event has already been fired (when none were attached).

                  所以你必須在調用 send 之前附加處理程序.

                  So you have to attach the handler before calling send.

                  這篇關于為什么我們在 XMLHttpRequest 中寫 send() 之前要寫 onload() 函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 部分內容)

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

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

                            主站蜘蛛池模板: 小型玉石雕刻机_家用玉雕机_小型万能雕刻机_凡刻雕刻机官网 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 深圳市索富通实业有限公司-可燃气体报警器 | 可燃气体探测器 | 气体检测仪 | 气弹簧定制-气动杆-可控气弹簧-不锈钢阻尼器-工业气弹簧-可调节气弹簧厂家-常州巨腾气弹簧供应商 | 硬齿面减速机_厂家-山东安吉富传动设备股份有限公司 | 隆众资讯-首页_大宗商品资讯_价格走势_市场行情 | 精密钢管,冷拔精密无缝钢管,精密钢管厂,精密钢管制造厂家,精密钢管生产厂家,山东精密钢管厂家 | 济南拼接屏_山东液晶拼接屏_济南LED显示屏—维康国际官网 | 液晶拼接屏厂家_拼接屏品牌_拼接屏价格_监控大屏—北京维康 | 河南新乡德诚生产厂家主营震动筛,振动筛设备,筛机,塑料震动筛选机 | 宿舍管理系统_智慧园区系统_房屋/房产管理系统_公寓管理系统 | 铜镍-康铜-锰铜-电阻合金-NC003 - 杭州兴宇合金有限公司 | 搜木网 - 木业全产业链交易平台,免费搜货、低价买货! | 底部填充胶_电子封装胶_芯片封装胶_芯片底部填充胶厂家-东莞汉思新材料 | 深圳昂为官网-气体分析仪,沼气分析仪,动态配气仪,气体传感器厂家 | 烘干设备-热泵烘干机_广东雄贵能源设备有限公司 | 森旺-A级防火板_石英纤维板_不燃抗菌板装饰板_医疗板 | 山东商品混凝土搅拌楼-环保型搅拌站-拌合站-分体仓-搅拌机厂家-天宇 | 外贮压-柜式-悬挂式-七氟丙烷-灭火器-灭火系统-药剂-价格-厂家-IG541-混合气体-贮压-非贮压-超细干粉-自动-灭火装置-气体灭火设备-探火管灭火厂家-东莞汇建消防科技有限公司 | 深圳宣传片制作_产品视频制作_深圳3D动画制作公司_深圳短视频拍摄-深圳市西典映画传媒有限公司 | 带式压滤机_污泥压滤机_污泥脱水机_带式过滤机_带式压滤机厂家-河南恒磊环保设备有限公司 | 钢骨架轻型板_膨石轻型板_钢骨架轻型板价格_恒道新材料 | 编织人生 - 权威手工编织网站,编织爱好者学习毛衣编织的门户网站,织毛衣就上编织人生网-编织人生 | 七维官网-水性工业漆_轨道交通涂料_钢结构漆 | 常州律师事务所_常州律所_常州律师-江苏乐天律师事务所 | 杭州中策电线|中策电缆|中策电线|杭州中策电缆|杭州中策电缆永通集团有限公司 | 苏州伊诺尔拆除公司_专业酒店厂房拆除_商场学校拆除_办公楼房屋拆除_家工装拆除拆旧 | 航拍_专业的无人机航拍摄影门户社区网站_航拍网 | 盘古网络技术有限公司| 壹车网 | 第一时间提供新车_资讯_报价_图片_排行! | 颗粒机,颗粒机组,木屑颗粒机-济南劲能机械有限公司 | 诸城网站建设-网络推广-网站优化-阿里巴巴托管-诸城恒泰互联 | 广州冷却塔维修厂家_冷却塔修理_凉水塔风机电机填料抢修-广东康明节能空调有限公司 | 滁州高低温冲击试验箱厂家_安徽高低温试验箱价格|安徽希尔伯特 | 激光内雕_led玻璃_发光玻璃_内雕玻璃_导光玻璃-石家庄明晨三维科技有限公司 激光内雕-内雕玻璃-发光玻璃 | 权威废金属|废塑料|废纸|废铜|废钢价格|再生资源回收行情报价中心-中废网 | 沈阳庭院景观设计_私家花园_别墅庭院设计_阳台楼顶花园设计施工公司-【沈阳现代时园艺景观工程有限公司】 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 芝麻黑-芝麻黑石材厂家-永峰石业 | 带压开孔_带压堵漏_带压封堵-菏泽金升管道工程有限公司 | 高低温试验箱-模拟高低温试验箱订制-北京普桑达仪器科技有限公司【官网】 |