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 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]


Удаленная работа для программистов  •  Как заработать на 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

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