You are here: Re: How to send data a little at a time? « PHP Programming Language « IT news, forums, messages
Re: How to send data a little at a time?

Posted by Mike Willbanks on 10/18/05 05:29

> I have a script that makes multiple requests to several sites. However,
> each request takes a little while. How can I get the PHP script to
> output data to let the user know that it's checking? For example, I have
>
> echo "Checking...";
>
> at the beginning, before I do any hocus-pocus, but it doesn't show up
> until the script is done. How do I get it to send some data at a time?

This can be a little difficult. For certain browsers they will not
display anything until there is a certain byte size reached. However
there are a few ways... I will take you through a few of them.

1) Create an image that tells them it is processing when they click it,
show it when the user clicks submit and then hide it on completion.

2) The AJAX way
If you want to make an AJAX request it is far easier than flushing the
output. For instance if you use AjaxRequest (www.ajaxtoolbox.com), you
could use the onLoading to display the contents as they are flushed to
the browser, then onSuccess when it is finished. See the examples for
details on how to implement this.


3) The harder way (requires some research)
You can use flush from php, but this doesn't always work correctly. See
the manual for an explaination (http://www.php.net/flush)

I would suggest using AJAX as you can take that content and replace it
into the current area after you have processed it.



--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com

 

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

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