Reputation: 169
If a user clicks a button that will make an ajax post call to a php file, then navigates away from the website or closes the window, will the php file run completely until it finishes?
i want the file to download stuff to my server and post a bunch of information into a mysql database. This could take a minute or two. But i want the task to finish completely no matter what the user does.
if the ajax post/request gets sent, will the file run through completely?
thanks for any info.
Upvotes: 3
Views: 160
Reputation: 11547
this helped me understand:
http://www.php.net/manual/en/features.connection-handling.php
Upvotes: 0
Reputation: 48284
This should help:
ignore_user_abort(true);
set_time_limit(0); // number of seconds (0 infinity)
Check out the documentation for those two functions for more insight. In general, you shouldn't have a problem, as long as you don't run up against the time limit. This should have all the info you need:
https://www.php.net/manual/en/features.connection-handling.php
Upvotes: 6