Synchronous Ajax - does Chrome have a timeout on trusted events?

后端 未结 3 1736
忘了有多久
忘了有多久 2021-02-05 13:25

Situation

We have a situation, where we need to onclick-open a new tab in browsers after performing an XHR / Ajax request.

We do this by setti

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 14:11

    What might fix this is opening the new tab before the XHR request returns and while you are still in the trusted context. Browser tabs and windows opened via Javascript maintain connections with the parent window and can communicate back and forth.

    If you open a new tab when a link is clicked, you can show a loading screen in the new window while the XHR call runs. This workflow isn't quite as clean as your original request, but it would be a viable solution with some thought. The script below is just a quick example using window.setTimeout() to simulate an async XHR request.

    
    
        

    Hello

    Make http call and open window.

提交回复
热议问题