Change page in the middle of Ajax request

前端 未结 5 565
面向向阳花
面向向阳花 2021-01-17 12:07

What happens if I send some ajax request, and immediately change the page (say follow some link) before the request returns? I mean I suppose the XHR object sends a request

5条回答
  •  时光说笑
    2021-01-17 12:28

    You would be out of luck. You would have no callback to come back to. Ajax response would be lost. In this case I would put a blocker on the page. It's pretty common, in order to prevent another click. Blocker nothing more than big mask which "lays over" the entire browser. It could also have a wait icon.

提交回复
热议问题