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

    1. <legend id='XaGLV'><style id='XaGLV'><dir id='XaGLV'><q id='XaGLV'></q></dir></style></legend>

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

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

      JavaScript 如何在后臺處理 AJAX 響應(yīng)?

      How does JavaScript handle AJAX responses in the background?(JavaScript 如何在后臺處理 AJAX 響應(yīng)?)

      <legend id='fDt0O'><style id='fDt0O'><dir id='fDt0O'><q id='fDt0O'></q></dir></style></legend>
        <tbody id='fDt0O'></tbody>

          <bdo id='fDt0O'></bdo><ul id='fDt0O'></ul>
            1. <tfoot id='fDt0O'></tfoot>

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

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

                本文介紹了JavaScript 如何在后臺處理 AJAX 響應(yīng)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                由于 JavaScript 在單線程中運行,在發(fā)出 AJAX 請求后,后臺實際發(fā)生了什么?我想對此有更深入的了解,有人能解釋一下嗎?

                Since JavaScript runs in a single thread, after an AJAX request is made, what actually happens in the background? I would like to get a deeper insight into this, can anyone shed some light?

                推薦答案

                在底層,javascript 有一個事件隊列.每次 javascript 線程執(zhí)行完成時,它都會檢查隊列中是否有另一個事件要處理.如果有,它會將其從隊列中拉出并觸發(fā)該事件(例如鼠標(biāo)單擊).

                Below the covers, javascript has an event queue. Each time a javascript thread of execution finishes, it checks to see if there is another event in the queue to process. If there is, it pulls it off the queue and triggers that event (like a mouse click, for example).

                位于 ajax 調(diào)用下的本機代碼網(wǎng)絡(luò)將知道 ajax 響應(yīng)何時完成,并且事件將被添加到 javascript 事件隊列中.本機代碼如何知道 ajax 調(diào)用何時完成取決于實現(xiàn).它可以用線程實現(xiàn),也可以由事件驅(qū)動本身(這并不重要).實現(xiàn)的重點是,當(dāng)ajax響應(yīng)完成后,一些native代碼會知道它已經(jīng)完成,并將一個事件放入JS隊列中.

                The native code networking that lies under the ajax call will know when the ajax response is done and an event will get added to the javascript event queue. How the native code knows when the ajax call is done depends upon the implementation. It may be implemented with threads or it may also be event driven itself (it doesn't really matter). The point of the implementation is that when the ajax response is done, some native code will know it's done and put an event into the JS queue.

                如果當(dāng)時沒有 Javascript 正在運行,則將立即觸發(fā)該事件,該事件將運行 ajax 響應(yīng)處理程序.如果當(dāng)時正在運行某些東西,那么當(dāng)當(dāng)前執(zhí)行的 javascript 線程完成時,將處理該事件.javascript引擎不需要進行任何輪詢.當(dāng)一段 Javascript 完成執(zhí)行時,JS 引擎只是檢查事件隊列以查看是否還有其他需要運行的內(nèi)容.如果是這樣,它會從隊列中彈出下一個事件并執(zhí)行它(調(diào)用為該事件注冊的一個或多個回調(diào)函數(shù)).如果事件隊列中沒有任何內(nèi)容,則 JS 解釋器有空閑時間(垃圾收集或空閑),直到某個外部代理將其他內(nèi)容放入事件隊列并再次喚醒它.

                If no Javascript is running at the time, the event will be immediately triggered which will run the ajax response handler. If something is running at the time, then the event will get processed when the current javascript thread of execution finishes. There doesn't need to be any polling by the javascript engine. When a piece of Javascript finishes executing, the JS engine just checks the event queue to see if there is anything else that needs to run. If so, it pops the next event off the queue and executes it (calling one or more callback functions that are registered for that event). If nothing is in the event queue, then the JS interpreter has free time (garbage collection or idle) until some external agent puts something else in the event queue and wakes it up again.

                因為所有外部事件都經(jīng)過事件隊列,并且在 javascript 實際運行其他東西時不會觸發(fā)任何事件,所以它保持單線程.

                Because all outside events go through the event queue and no event is ever triggered while javascript is actually running something else, it stays single threaded.

                這里有一些關(guān)于細節(jié)的文章:

                Here are some articles on the details:

                • Javascript 定時器如何工作 - 由 John Resig 編寫
                • 事件和時序深度
                • W3 規(guī)范:HTML5 事件循環(huán)
                • 關(guān)于事件循環(huán)的 MDN 文章
                • JS 事件隊列演示
                • JavaScript 事件循環(huán):解釋
                • 幫助馴服異步 Javascript 的五種模式
                • Javascript 事件循環(huán)演示
                • 視頻討論 Javascript 的工作原理(包括 10:27 的事件循環(huán))

                這篇關(guān)于JavaScript 如何在后臺處理 AJAX 響應(yīng)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)容)
                <legend id='hYk93'><style id='hYk93'><dir id='hYk93'><q id='hYk93'></q></dir></style></legend>
              • <i id='hYk93'><tr id='hYk93'><dt id='hYk93'><q id='hYk93'><span id='hYk93'><b id='hYk93'><form id='hYk93'><ins id='hYk93'></ins><ul id='hYk93'></ul><sub id='hYk93'></sub></form><legend id='hYk93'></legend><bdo id='hYk93'><pre id='hYk93'><center id='hYk93'></center></pre></bdo></b><th id='hYk93'></th></span></q></dt></tr></i><div class="t7r75nx" id='hYk93'><tfoot id='hYk93'></tfoot><dl id='hYk93'><fieldset id='hYk93'></fieldset></dl></div>
                  <tbody id='hYk93'></tbody>
                • <bdo id='hYk93'></bdo><ul id='hYk93'></ul>

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

                      <tfoot id='hYk93'></tfoot>
                          主站蜘蛛池模板: 板式换热器_板式换热器价格_管式换热器厂家-青岛康景辉 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 国产液相色谱仪-超高效液相色谱仪厂家-上海伍丰科学仪器有限公司 | 网架支座@球铰支座@钢结构支座@成品支座厂家@万向滑动支座_桥兴工程橡胶有限公司 | 粉末包装机-给袋式包装机-全自动包装机-颗粒-液体-食品-酱腌菜包装机生产线【润立机械】 | 成都热收缩包装机_袖口式膜包机_高速塑封机价格_全自动封切机器_大型套膜机厂家 | 全自动烧卖机厂家_饺子机_烧麦机价格_小笼汤包机_宁波江北阜欣食品机械有限公司 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 邢台人才网_邢台招聘网_邢台123招聘【智达人才网】 | 谈股票-今日股票行情走势分析-牛股推荐排行榜 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | SDG吸附剂,SDG酸气吸附剂,干式酸性气体吸收剂生产厂家,超过20年生产使用经验。 - 富莱尔环保设备公司(原名天津市武清县环保设备厂) | LED太阳能中国结|发光红灯笼|灯杆造型灯|节日灯|太阳能灯笼|LED路灯杆装饰造型灯-北京中海轩光电 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 真空包装机-诸城市坤泰食品机械有限公司 | 德国BOSCH电磁阀-德国HERION电磁阀-JOUCOMATIC电磁阀|乾拓百科 | 轴流风机-鼓风机-离心风机-散热风扇-罩极电机,生产厂家-首肯电子 | 镀锌钢格栅_热镀锌格栅板_钢格栅板_热镀锌钢格板-安平县昊泽丝网制品有限公司 | 广州展台特装搭建商|特装展位设计搭建|展会特装搭建|特装展台制作设计|展览特装公司 | 药品冷藏箱厂家_低温冰箱_洁净工作台-济南欧莱博电子商务有限公司官网 | 全自动包装秤_全自动上袋机_全自动套袋机_高位码垛机_全自动包装码垛系统生产线-三维汉界机器(山东)股份有限公司 | 无痕胶_可移胶_无痕双面胶带_可移无痕胶厂家-东莞凯峰 | 阿尔法-MDR2000无转子硫化仪-STM566 SATRA拉力试验机-青岛阿尔法仪器有限公司 | 食药成分检测_调料配方还原_洗涤剂化学成分分析_饲料_百检信息科技有限公司 | 稳尚教育加盟-打造高考志愿填报平台_新高考志愿填报加盟_学业生涯规划加盟 | 广州番禺搬家公司_天河黄埔搬家公司_企业工厂搬迁_日式搬家_广州搬家公司_厚道搬迁搬家公司 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 蒜肠网-动漫,二次元,COSPLAY,漫展以及收藏型模型,手办,玩具的新媒体.(原变形金刚变迷TF圈) | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | 杭州实验室尾气处理_实验台_实验室家具_杭州秋叶实验设备有限公司 | 专注提供国外机电设备及配件-工业控制领域一站式服务商-深圳市华联欧国际贸易有限公司 | 无机纤维喷涂棉-喷涂棉施工工程-山东华泉建筑工程有限公司▲ | 硫化罐-胶管硫化罐-山东鑫泰鑫智能装备有限公司 | 非小号行情 - 专业的区块链、数字藏品行情APP、金色财经官网 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 电竞馆加盟,沈阳网吧加盟费用选择嘉棋电竞_售后服务一体化 | 小型数控车床-数控车床厂家-双头数控车床 | 世界箱包品牌十大排名,女包小众轻奢品牌推荐200元左右,男包十大奢侈品牌排行榜双肩,学生拉杆箱什么品牌好质量好 - Gouwu3.com | 山东彩钢板房,山东彩钢活动房,临沂彩钢房-临沂市贵通钢结构工程有限公司 |