|
Posted by aonic on 04/13/07 20:20
On Apr 13, 5:25 am, "Marvin Zhang" <zyem...@gmail.com> wrote:
> Hi,
>
> I'm not familiar with web programming, but I have a problem here.
>
> I have a page. When a user click one button on it, I will use AJAX to
> request a PHP script which will do a bunch of tasks, asynchronously.
> These tasks might take long time so I want to keep the user informed
> of the progress. The problem is that only the PHP script knows the
> progress, how can the web page gets these information from PHP script?
>
> I'd really appreciated if someone could help me solve this problem.
You might want to look at Comet http://en.wikipedia.org/wiki/Comet_%28programming%29
Comet is a programming technique that enables web servers to send data
to the client without having any need for the client to request it. It
allows creation of event-driven web applications which are hosted in
the browser.
Another solution is to not use AJAX, but a hidden iframe, load your
page into the iframe and while the php is running make it output
javascript that will update the status on the main page.
Example:
for($x = 0; $x < 10; $x++) {
echo '<script>window.parent.updateStatus('.$x.');</script>';
flush();
}
Check here for more info on iframe remote scripting
http://developer.apple.com/internet/webcontent/iframe.html
Navigation:
[Reply to this message]
|