0

I'm coding a web application using SoX with the PHP exec() function.

Problem, SoX is a bit slow, and takes sometimes more than a minute to finish its task.

I'm trying to code a progress bar to let the user know that the web page has not crashed and SoX is still doing its job.

So far, I have a php page using the exec command and using callbacks. For each callback, I'm adding javascript code and call flush() to update the progress bar. So, it's the PHP updating the progress bar, meaning that the page is not ready until php is done with SoX.

Is this the best way to do this? I have seen some people using Ajax, loop and timers to manualy fetch data from PHP and update the progress bar. Is is more appropriate?

Thanks.

[EDIT] So after some comments, here is another question : If I start a php script, will the script keep going even if I Ajax to another page?

Sunbird
  • 11
  • 4
  • I would suggest to go with the AJAX approach and provide php endpoint for your tasks. You then can use the status of the xhr call to give the user feedback. – Luketep May 02 '14 at 07:25
  • I searched for PHP endpoint, but I'm not sure to understand what it is for. – Sunbird May 02 '14 at 07:39
  • That's the url for your ajax call. The php code in the file is reading the information from client, processing it and responding. – Luketep May 02 '14 at 08:14
  • Oh I see now! But it means I have to run the SoX php script in an other thread, right? – Sunbird May 02 '14 at 08:17

0 Answers0