I'm trying to update script users of it's progress, instead of waiting for it to fully execute..
For example, I'm calling different web links to get specific messages (REST web services).
I might need to call 10-20 URLs , so , I want to update users of the state of each URL once it's fetched , and not waiting for the whole 10-20 to complete.
Tried the following:
ob_start();
while(xxx):
$result = call_url($url); // my custom function of performing web service call
echo $result;
ob_flush();
endwhile;
Doesn't do the expected.... Any clue?
When you run that loop the print to browser is not async. It may only print once the loop is done.
I would suggest you to use as Ajax Queue and fire those calls one by one. Ajax is async only that way you can update your users.
Or you can write to a file some good meta data after every loop iteration that you can feed to an Observer which again is Ajax call to read that file and show progress to the user