I have some php script updater.php which does some job for 1-2 minutes. Finishing the script job is important.
I can run it with cron, but i have some idea.
Script will run concrete time only when user gets for example home page. In this case it’s unnecessary to execute script every time, only when it’s needed.
So, user loads http://localhost/index.php, js script post small get request:
$.get('/json/updater.php', function(data){ return true; });
Requests proceed good in 1-2 minutes.
The question: Will processing of updater.php work stop, if user closes the tab in browser and therefore break $.get request?
Requests don’t get cancelled if you close the browser window, so PHP will simply be able to complete the script (assuming the execution time doesn’t exceed the maximum configured time See: http://php.net/manual/en/function.set-time-limit.php). Of course, anything you do in JavaScript will stop once you close the window.