問題描述
我一直在網上搜索,試圖找到一個直接的答案.有誰知道瀏覽器 ajax 請求的默認超時長度?如果它改變了,也按版本?
I've been scouring the web trying to find a straight answer to this. Does anyone know the default timeout lengths for ajax request by browser? Also by version if it's changed?
推薦答案
我認為瀏覽器沒有AJAX超時,只有同步或異步請求;同步 - 首先凍結 JavaScript 執行,直到請求返回,異步 - 不凍結 JavaScript 執行,它只是將請求從執行流程中取出,如果您有回調函數,它將與正在運行的腳本并行執行該函數(類似于線程)
I don't think browsers have a timeout for AJAX, there is only synchronous or asynchronous requests; synchronous - first freezes the JavaScript execution until the request returns, asynchronous - does not freeze JavaScript execution, it simply takes the request out of the execution flow, and if you have a callback function it will execute the the function in parallel with the running scripts (similar to a thread)
**sync flow:**
running JS script
|
ajax
(wait for response)
|
execute callback
|
running JS script
**async flow:**
running JS script
|
ajax --------------------
| |
running JS script execute callback
這篇關于瀏覽器的 AJAX (XmlHttpRequest) 超時長度的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!