|
Posted by Marvin Zhang on 04/18/07 02:57
> Just an idea, someone who's done it may know better.
>
> - Have your original PHP store it's "status" information in a Session
> variable says $_SESSION["status_data"] which is updates as it runs
>
> - Have a timer on the Javascript side which creates a 2nd Ajax call
> to a new getstatus.php, which then reads the status from the session and
> sends back to the browser in this 2nd Ajax call.
>
> Not done much Ajax, I am assuming you can make another ajax call whilst
> one is currently running??
>
> You might need to send the PHP session id back to the server when you
> call getstatus.php, not sure.
>
> Let us no how you do :)
I've tried out this approach. But unfortunately, there's a problem
prevent this solution from working. If we send more than one request
to the same session, all the requests will be queued. The second
request will be send only after the response of the first request is
received. So it's impossible to poll the information with second AJAX
request.
I'm planning to use a table in the database to record process
information. The PHP script at the server side will update the record
in the table and the web page sends request regularly to poll the
information from database, just the same as you suggested. This will
work cause we don't need to use session here. Using database, not only
PHP script but also the daemon written in C++ can update that
infomantion, this is what I need.
Anyway, thanks for you original idea. That really helps very much :)
Navigation:
[Reply to this message]
|