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

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

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

問題描述

如果用戶導(dǎo)航到另一個(gè)頁面,我想中止一些(可能)長時(shí)間運(yùn)行的 ajax 調(diào)用.以下 jQuery 代碼在離開頁面時(shí)對所有待處理的 XMLHttpRequest 對象調(diào)用 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();
        });
    }
});

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

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.

推薦答案

感謝您的回復(fù)!事實(shí)證明,我完全錯(cuò)誤地認(rèn)為這是一個(gè)瀏覽器問題——問題出在服務(wù)器上.ASP.NET 對需要會話狀態(tài)的同一會話的請求進(jìn)行序列化,因此在這種情況下,直到那些由 ajax 發(fā)起的請求完成后,下一頁才開始在服務(wù)器上處理.

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.

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

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.

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

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

相關(guān)文檔推薦

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)容)
Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
主站蜘蛛池模板: 九色 在线| 国产一级片一区二区 | 欧美精品福利视频 | 波多野结衣一区二区 | 亚洲精品一区二区久 | 久久一区二区三区免费 | 久久久激情视频 | 国产福利91精品一区二区三区 | 国产精品99久久久久久动医院 | 欧美午夜一区 | 欧美日韩中文在线 | 国产亚洲精品成人av久久ww | 亚洲一区二区中文字幕 | 国产免费一二三区 | 国产色婷婷精品综合在线播放 | 特一级黄色毛片 | 亚洲九色 | 亚洲国产网站 | 国产福利在线小视频 | 欧美一区二区综合 | 亚洲三级免费看 | 亚洲精品片 | 午夜极品 | 丁香五月网久久综合 | 在线观看中文视频 | 欧美久久久电影 | 欧美在线观看一区 | 一级片片| 亚洲国产精品一区二区第一页 | 日韩一区二区三区在线 | 亚洲最大福利网 | 伊人天堂网 | 影音先锋中文字幕在线观看 | 国产精品欧美一区二区三区不卡 | 欧美激情国产日韩精品一区18 | 亚洲精品日韩在线 | 国产91丝袜在线播放 | 伊人亚洲 | 99福利视频 | 黄网站涩免费蜜桃网站 | 91精品久久 |