AJAX (XmlHttpRequest) timeout length by browser

前端 未结 4 2063
庸人自扰
庸人自扰 2020-12-30 02:35

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 chan

4条回答
  •  误落风尘
    2020-12-30 03:16

    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
    

提交回复
热议问题