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

    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="qwawimqqmiuu" id='XaGLV'><tfoot id='XaGLV'></tfoot><dl id='XaGLV'><fieldset id='XaGLV'></fieldset></dl></div>
      • <bdo id='XaGLV'></bdo><ul id='XaGLV'></ul>

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

      How does JavaScript handle AJAX responses in the background?(JavaScript 如何在后臺(tái)處理 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="qwawimqqmiuu" id='fDt0O'><tfoot id='fDt0O'></tfoot><dl id='fDt0O'><fieldset id='fDt0O'></fieldset></dl></div>

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

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

                問題描述

                由于 JavaScript 在單線程中運(yùn)行,在發(fā)出 AJAX 請(qǐng)求后,后臺(tái)實(shí)際發(fā)生了什么?我想對(duì)此有更深入的了解,有人能解釋一下嗎?

                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 有一個(gè)事件隊(duì)列.每次 javascript 線程執(zhí)行完成時(shí),它都會(huì)檢查隊(duì)列中是否有另一個(gè)事件要處理.如果有,它會(huì)將其從隊(duì)列中拉出并觸發(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)用下的本機(jī)代碼網(wǎng)絡(luò)將知道 ajax 響應(yīng)何時(shí)完成,并且事件將被添加到 javascript 事件隊(duì)列中.本機(jī)代碼如何知道 ajax 調(diào)用何時(shí)完成取決于實(shí)現(xiàn).它可以用線程實(shí)現(xiàn),也可以由事件驅(qū)動(dòng)本身(這并不重要).實(shí)現(xiàn)的重點(diǎn)是,當(dāng)ajax響應(yīng)完成后,一些native代碼會(huì)知道它已經(jīng)完成,并將一個(gè)事件放入JS隊(duì)列中.

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

                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.

                因?yàn)樗型獠渴录冀?jīng)過(guò)事件隊(duì)列,并且在 javascript 實(shí)際運(yùn)行其他東西時(shí)不會(huì)觸發(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)于細(xì)節(jié)的文章:

                Here are some articles on the details:

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

                這篇關(guān)于JavaScript 如何在后臺(tái)處理 AJAX 響應(yīng)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 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 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (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="qwawimqqmiuu" 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>
                          主站蜘蛛池模板: 欧美在线观看网站 | 九九九久久国产免费 | 日本不卡在线观看 | 蜜桃一区 | 91av久久久| 人人澡人人射 | av黄色免费在线观看 | 国产精品久久久久久久久久久久 | 久草影视在线 | 国产综合久久久久久鬼色 | 九九热免费在线观看 | 亚洲一区二区av在线 | 久久国产精品99久久久久 | 国产 欧美 日韩 一区 | 免费一级欧美在线观看视频 | 久久99精品久久久 | 中文字幕av网站 | 国产精品亚洲一区二区三区在线观看 | 天天操综合网站 | 国产精品a久久久久 | 亚洲a在线视频 | 妖精视频一区二区三区 | 欧美1区2区| 成人三区 | 国产精品中文在线 | 久久69精品久久久久久国产越南 | 国产精品久久久久久久久免费软件 | 亚洲日本免费 | 人操人人干人 | 欧美激情精品久久久久久变态 | 成人亚洲| 国产一区二区三区在线观看免费 | www久| 久久久激情 | 成人在线观看亚洲 | 成人av鲁丝片一区二区小说 | 国产黄色小视频在线观看 | 日本精品视频在线观看 | 色综合一区二区 | 老司机午夜性大片 | 久久综合香蕉 |