I implement progress-bar script execution in pkhp. On the start button, I run the PCP script with the Ajax and get data on the progress. Next you need to click on another button to stop the execution of the php script. how to stop execution of php from ajax?

  • one
    for example, write in a stop session. but in the main script check - splash58
  • @ splash58 can be more? not quite clear - Max
  • ajax calls the script on the server, it writes a signal to stop, the main script in the loop checks for the presence of such a signal and stops as it detects. - splash58
  • @ splash58, right? session_start (); if (! isset ($ _ SESSION ['stop'])) $ _ SESSION ['stop'] = 0; if ($ _ POST ['stop']) $ _ SESSION ['stop'] = 1; for ($ i = 1; $ i <= 10; $ i ++) {if ($ _ SESSION ['stop']) {$ _ SESSION ['stop'] = 0; break;} $ _SESSION ['progress'] = $ i * 10; session_write_close (); sleep (1); } exit (); - Max
  • somehow, probably so - splash58

0