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

即使在調用 abort (jQuery) 之后,瀏覽器也會等待

Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
本文介紹了即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果用戶導航到另一個頁面,我想中止一些(可能)長時間運行的 ajax 調用.以下 jQuery 代碼在離開頁面時對所有待處理的 XMLHttpRequest 對象調用 abort:

I have some (potentially) long-running ajax calls that I would like to abort if the user navigates to another page. The following jQuery code calls abort on all pending XMLHttpRequest objects upon navigating away from the page:

$.ajaxSetup({
    beforeSend: function(xhr) {
        $(window).bind('beforeunload', function() {
            xhr.abort();
        });
    }
});

在一個測試用例中,我強制等待被調用的服務器端操作等待 10 秒.使用 Firebug,我確認當我單擊頁面上的任何鏈接時,上述代碼確實會導致所有掛起的 ajax 調用立即停止.但是,瀏覽器仍會等待整整 10 秒,然后才能轉到下一頁.IE 似乎表現出相同的行為.這是已知的瀏覽器行為嗎?在這種情況下,我能做些什么讓用戶立即離開頁面?提前致謝.

In a test case, I force a 10-second wait on the server-side operation being called. Using Firebug, I confirmed that the above code does indeed cause all pending ajax calls to halt immediately when I click any link on the page. However, the browser still waits the full 10 seconds before moving on to the next page. IE appears to exhibit the same behavior. Is this a known browser behavior? Is there anything I can do allow the user to navigate away from the page immediately in this situation? Thanks in advance.

推薦答案

感謝您的回復!事實證明,我完全錯誤地認為這是一個瀏覽器問題——問題出在服務器上.ASP.NET 對需要會話狀態的同一會話的請求進行序列化,因此在這種情況下,直到那些由 ajax 發起的請求完成后,下一頁才開始在服務器上處理.

Thank you for your replies! It turns out I was completely wrong about this being a browser issue - the problem was on the server. ASP.NET serializes requests of the same session that require session state, so in this case, the next page didn't begin processing on the server until those ajax-initiated requests completed.

不幸的是,在這種情況下,響應 ajax 調用的 http 處理程序需要會話狀態.但是只讀訪問已經足夠好了,因此通過使用 IReadOnlySessionState 而不是 IRequiresSessionState 標記處理程序,會話鎖不會被持有并且問題得到解決.

Unfortunately, in this case, session state is required in the http handler that responded to the ajax calls. But read-only access is good enough, so by marking the handler with IReadOnlySessionState instead of IRequiresSessionState, session locks are not held and the problem is fixed.

希望這些信息對其他人有用.

Hope this information proves useful to others.

這篇關于即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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 部分內容)
Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
主站蜘蛛池模板: 国产精品久久久久一区二区 | 亚洲视频区 | 久久精品视频9 | 久在线观看 | 国产精品夜夜夜一区二区三区尤 | 欧美日韩一区二区在线观看 | 99精品国产一区二区三区 | 国产欧美一区二区三区在线看 | 密色视频 | 日韩最新网站 | 成人一区二区三区在线观看 | 在线一区视频 | 日本一区二区影视 | 国产成人精品一区二区三区网站观看 | 超碰男人天堂 | 精品久久久久久久久久久久久久 | 亚洲综合色自拍一区 | 韩日精品一区 | 在线观看中文字幕视频 | 亚洲欧洲精品一区 | 中文字幕高清 | 综合久久久 | www国产精品 | 久久精品亚洲欧美日韩久久 | 99精品视频在线 | 国产日韩欧美二区 | 99pao成人国产永久免费视频 | 成人日韩| 久久aⅴ乱码一区二区三区 亚洲国产成人精品久久久国产成人一区 | 国产午夜精品一区二区三区嫩草 | 中文字幕成人 | 天堂在线网 | 成人精品一区二区三区中文字幕 | 日韩av在线中文字幕 | 精品国产乱码久久久久久丨区2区 | 欧美国产日韩一区二区三区 | 午夜精品在线观看 | 免费成人高清 | 国产综合区 | 国产精品麻 | 91在线一区二区 |