mctrivia Posted May 24, 2011 Share Posted May 24, 2011 is it possible to get an ajax call to execute a php script that will continue running even if the user leaves my site? i have used cron jobs and tokens to do in past but this can result in 1 min delay. Quote Link to comment https://forums.phpfreaks.com/topic/237344-ajax-triggering-long-job/ Share on other sites More sharing options...
The Little Guy Posted May 24, 2011 Share Posted May 24, 2011 how does a cron job not work? Quote Link to comment https://forums.phpfreaks.com/topic/237344-ajax-triggering-long-job/#findComment-1219629 Share on other sites More sharing options...
mctrivia Posted May 24, 2011 Author Share Posted May 24, 2011 because i can only set cron jobs to run every minute. not every second. Quote Link to comment https://forums.phpfreaks.com/topic/237344-ajax-triggering-long-job/#findComment-1219647 Share on other sites More sharing options...
The Little Guy Posted May 24, 2011 Share Posted May 24, 2011 why do you need it to run so much? Quote Link to comment https://forums.phpfreaks.com/topic/237344-ajax-triggering-long-job/#findComment-1219682 Share on other sites More sharing options...
xyph Posted May 24, 2011 Share Posted May 24, 2011 PHP should finish executing the code once started, regardless of what the user does. Using the code below, running the script then closing browser immediately still results in a MySQL insert. <?php sleep( 10 ); $c = mysql_connect( 'localhost', 'root', '' ); mysql_select_db( 'test', $c ); $q = 'INSERT INTO `test` SET `start` = NOW()'; mysql_query( $q ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/237344-ajax-triggering-long-job/#findComment-1219693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.