You are here: Re: Using AJAX, how can the page get state infomation from backgroud PHP script? « PHP Programming Language « IT news, forums, messages
Re: Using AJAX, how can the page get state infomation from backgroud PHP script?

Posted by Jerry Stuckle on 04/18/07 12:58

Marvin Zhang wrote:
>> 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 :)
>

Yes, your problem is PHP serializes access to session data. For the
second request the be processed, the first request must either complete
or otherwise close the session (i.e. session_write_close()).

But if you close the session you can't reopen it in your long-running
script.

Your database idea should work great.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация