久久久久久久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() 的限制?)
主站蜘蛛池模板: 日韩a视频 | 日韩精品中文字幕一区二区三区 | 男女视频在线观看 | 国产成人久久精品一区二区三区 | 蜜桃视频在线观看免费视频网站www | 涩涩视频在线观看免费 | 国产精品国产成人国产三级 | 日本久久久一区二区三区 | 99re国产| 无毛av| 久久久精选 | 9久9久| 精品久久一 | caoporn国产精品免费公开 | 99久久婷婷国产亚洲终合精品 | 国产精品99久久久久久久久 | 九九综合| 黄网站免费观看 | 亚洲一区二区在线视频 | 免费精品久久久久久中文字幕 | 国产午夜精品一区二区三区在线观看 | 精品毛片 | 在线成人精品视频 | 久久国产综合 | 久久五月婷| 一区二区不卡 | 999久久 | 户外露出一区二区三区 | 欧美又大粗又爽又黄大片视频 | 国产在线色 | 成人精品一区二区三区中文字幕 | 久久久久久看片 | 久久精品视频在线观看 | 久久久精品网站 | 国产成人a亚洲精品 | 国产剧情一区 | 国产精品一区久久久 | caoporn视频| 国产超碰人人爽人人做人人爱 | 国产91久久久久久久免费 | 亚洲成人网在线播放 |