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="j5lxn7r" 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="5rddzl7" 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="r5jvtxl" 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'>

                            主站蜘蛛池模板: LZ-373测厚仪-华瑞VOC气体检测仪-个人有毒气体检测仪-厂家-深圳市深博瑞仪器仪表有限公司 | 西门子气候补偿器,锅炉气候补偿器-陕西沃信机电工程有限公司 | 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 电镀标牌_电铸标牌_金属标贴_不锈钢标牌厂家_深圳市宝利丰精密科技有限公司 | 涿州网站建设_网站设计_网站制作_做网站_固安良言多米网络公司 | 常州翔天实验仪器厂-恒温振荡器-台式恒温振荡器-微量血液离心机 恒温恒湿箱(药品/保健品/食品/半导体/细菌)-兰贝石(北京)科技有限公司 | 脱硝喷枪-氨水喷枪-尿素喷枪-河北思凯淋环保科技有限公司 | 耳模扫描仪-定制耳机设计软件-DLP打印机-asiga打印机-fitshape「飞特西普」 | 污水处理设备-海普欧环保集团有限公司 | 碳钢法兰厂家,非标法兰,定制异型,法兰生产厂家-河北九瑞管道 | 酶联免疫分析仪-多管旋涡混合仪|混合器-莱普特科学仪器(北京)有限公司 | 电位器_轻触开关_USB连接器_广东精密龙电子科技有限公司 | WF2户外三防照明配电箱-BXD8050防爆防腐配电箱-浙江沃川防爆电气有限公司 | 小威小说网 - 新小威小说网 - 小威小说网小说搜索引擎 | 中原网视台| 塑木弯曲试验机_铜带拉伸强度试验机_拉压力测试台-倾技百科 | 特种阀门-调节阀门-高温熔盐阀-镍合金截止阀-钛阀门-高温阀门-高性能蝶阀-蒙乃尔合金阀门-福建捷斯特阀门制造有限公司 | 除甲醛公司-甲醛检测-广西雅居环境科技有限公司 | 氧化铝球_高铝球_氧化铝研磨球-淄博誉洁陶瓷新材料有限公司 | 运动木地板厂家_体育木地板安装_篮球木地板选购_实木运动地板价格 | 高压无油空压机_无油水润滑空压机_水润滑无油螺杆空压机_无油空压机厂家-科普柯超滤(广东)节能科技有限公司 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 | 铝机箱_铝外壳加工_铝外壳厂家_CNC散热器加工-惠州市铂源五金制品有限公司 | 高光谱相机-近红外高光谱相机厂家-高光谱成像仪-SINESPEC 赛斯拜克 | 石栏杆_青石栏杆_汉白玉栏杆_花岗岩栏杆 - 【石雕之乡】点石石雕石材厂 | 空气能暖气片,暖气片厂家,山东暖气片,临沂暖气片-临沂永超暖通设备有限公司 | 卫浴散热器,卫浴暖气片,卫生间背篓暖气片,华圣格浴室暖气片 | 深圳湾1号房价_深圳湾1号二手房源| 水上浮桥-游艇码头-浮动码头-游船码头-码瑞纳游艇码头工程 | 大巴租车平台承接包车,通勤班车,巴士租赁业务 - 鸿鸣巴士 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 广州网站建设_小程序开发_番禺网站建设_佛山网站建设_粤联网络 | 水厂自动化-水厂控制系统-泵站自动化|控制系统-闸门自动化控制-济南华通中控科技有限公司 | 一体化污水处理设备_生活污水处理设备_全自动加药装置厂家-明基环保 | 脉冲除尘器,除尘器厂家-淄博机械| 视觉检测设备_自动化检测设备_CCD视觉检测机_外观缺陷检测-瑞智光电 | 胃口福饺子加盟官网_新鲜现包饺子云吞加盟 - 【胃口福唯一官网】 | 碳纤维复合材料制品生产定制工厂订制厂家-凯夫拉凯芙拉碳纤维手机壳套-碳纤维雪茄盒外壳套-深圳市润大世纪新材料科技有限公司 | 农业四情_农业气象站_田间小型气象站_智慧农业气象站-山东风途物联网 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 |