I currently have a class Status
, and I call it throughout my code as I preform various tasks, for example - when I upload an image, I call $statusHandler = new Status(121)
, when I resize it, I call $statusHandler = new Status(122)
.
Every statusID corresponds to a certain text stored in the database.
Class status
retrieves the text, and stores in $_SESSION
.
I have another file, getstatus.php
, that returns the current status.
My idea was to call getstatus.php
every 500 miliseconds with ajax (via jquery), and append the text to the webpage.
This way the user gets (almost) real-time data about what calculations are going on in the background.
The problem is that I only seem to be getting the last status.
I thought that it just was a result of things happening too quickly, so I ran sleep
after calling new Status
. This delayed the entire output of the page, meaning PHP didn't output any text until it completed running through the code.
Does PHP echo data only after it finishes running through all the code, or does it do it real-time, line-by-line?
If so, can anyone offer any workarounds so that I can achieve what I want?
Teşekkürler.