Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an AJAX call to a php file --> then quit browser --> will the php file still run completely?

Tags:

ajax

post

php

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.

like image 830
benjaminlotan Avatar asked Dec 20 '25 14:12

benjaminlotan


1 Answers

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

like image 116
Matthew Avatar answered Dec 23 '25 07:12

Matthew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!