Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

php - What will happen when location.href is changed before ajax request completes?

  1. User clicks some link which execute some ajax request - lets say this request takes 20 secs.
  2. Before the request is complete user clicks oder link which redirects (no ajax) whole page to another page.

What will happen with ajax request? It will be always completed on server side but the response wont come anywhere? Or maybe ajax request on server side will be immidiately "killed?

I ask because I have some script which takes some time to run but user doesn't have to now the result - it's just fire and forget - maybe there is even some option in ajax to force it not to send any response?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The browser should kill the AJAX request, closing the connection to the server; however, this does not mean that your processing on the server is necessarily killed too: ignore_user_abort()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...