久久久久久久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 如何在后臺處理 AJAX 響應?

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

      <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 如何在后臺處理 AJAX 響應?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                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 線程執行完成時,它都會檢查隊列中是否有另一個事件要處理.如果有,它會將其從隊列中拉出并觸發該事件(例如鼠標單擊).

                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 調用下的本機代碼網絡將知道 ajax 響應何時完成,并且事件將被添加到 javascript 事件隊列中.本機代碼如何知道 ajax 調用何時完成取決于實現.它可以用線程實現,也可以由事件驅動本身(這并不重要).實現的重點是,當ajax響應完成后,一些native代碼會知道它已經完成,并將一個事件放入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.

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

                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.

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

                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.

                這里有一些關于細節的文章:

                Here are some articles on the details:

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

                這篇關于JavaScript 如何在后臺處理 AJAX 響應?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 部分內容)
                <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>
                          主站蜘蛛池模板: 91社影院在线观看 | 久草院线 | 亚洲国产精品一区二区久久 | 亚洲精品av在线 | 亚洲日本成人 | 91免费在线 | 免费观看一级特黄欧美大片 | 中文字幕一区在线观看视频 | 午夜免费电影院 | 国产精品免费视频一区 | 久久99精品久久 | 五月精品视频 | 国产丝袜一区二区三区免费视频 | 欧美全黄 | 黄色片网站在线观看 | 国产一级片91 | 欧美在线| 国产福利小视频 | 无人区国产成人久久三区 | 久久国产婷婷国产香蕉 | 国内自拍视频在线观看 | 日本高清视频网站 | 亚洲欧洲日韩精品 中文字幕 | 久久久噜噜噜www成人网 | 成人午夜激情 | 伊人网站视频 | 日韩三级电影一区二区 | 亚洲人在线播放 | 欧美一区二区二区 | 91在线精品秘密一区二区 | 毛色毛片免费看 | 91国自视频 | 国产精品久久久久久久久久 | 色爱综合 | 天天操夜夜拍 | 福利久久| 美女黄视频网站 | 久久黄网 | 国产一级淫片免费视频 | 精品一区二区三区在线观看国产 | 日韩在线免费视频 |