If we have such code:
window.location = 'http://example.net';
$.ajax({...});
Is any chance that the ajax code will be sent? Or there is no chance, that ajax request will be ever executed? thank you
If we have such code:
window.location = 'http://example.net';
$.ajax({...});
Is any chance that the ajax code will be sent? Or there is no chance, that ajax request will be ever executed? thank you
When the location
property is altered, the user agent begins to unload the current document in preparation for the loading of the new one. Only code that is registered into the document
or window
beforeunload
or unload
events will execute at that point.
The browser will try to execute the code after window.location until the page goes to the next web adress, so the number of lines of code that will be executed depends on the browser's speed
See What happens to code after a javascript redirect (setting window.location.href)?