'Will ajax call return successfully to reloaded web page?

I have a beginner question. If I make an ajax call using JavaScript, and then successfully reload the page before the ajax request gets a response, will the response still work?



Solution 1:[1]

No.

By reloading the page, all JavaScript (and its parser/engine) is terminated, reset and initialized again. So any pending (Ajax) calls are aborted. Hence, existing calls it will not work anymore.

Furthermore, all active (HTTP) connection are (should be) reset, so the server might still process the request (if it arrived on time), but the response is lost due to the aborted connections.

The fact that these things are not working after a reload, is a good thing: As it would result in unexpected, error-prone situations!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Veger