473,411 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

displaying text while page is loading

i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>

any help would be appreciated - thanks!

Jul 17 '05 #1
7 7071
yawnmoth wrote:
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>
Which browser are you using? If you use Internet Explorer this may be
interesting:

<quote src="http://es.php.net/flush">
Some versions of Microsoft Internet Explorer will only start to
display the page after they have received 256 bytes of output, so you
may need to send extra whitespace before flushing to get those browsers
to display the page.
</quote>

any help would be appreciated - thanks!

Jul 17 '05 #2

Dani CS wrote:
yawnmoth wrote:
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has fully loaded - which is not what i want (i want AAA to appear and then 10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:
<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>
Which browser are you using? If you use Internet Explorer this may be

interesting:

<quote src="http://es.php.net/flush">
Some versions of Microsoft Internet Explorer will only start to
display the page after they have received 256 bytes of output, so you may need to send extra whitespace before flushing to get those browsers to display the page.
</quote>


i've tried both IE and firefox (for windows) and get the same results...

Jul 17 '05 #3
yawnmoth wrote:
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>

any help would be appreciated - thanks!

Errr, you cant. A browser-webserver connection is stateless. The
browser will wait until the whole page has arrived before displaying
it, at which stage the web server and your php have allready forgotten
about you.

You *may* be able to do something using a http refresh in the <head> of
the page e.g.

page1.php:
echo '
<head>
<META HTTP-EQUIV=Refresh CONTENT="10; URL=http:page2.php">
</head>
<body>
AAA<br>
';

page2.php:
echo 'BBB<br>';
Jul 17 '05 #4
Sacs wrote:
yawnmoth wrote:
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>

any help would be appreciated - thanks!
Errr, you cant. A browser-webserver connection is stateless. The
browser will wait until the whole page has arrived before displaying it,
at which stage the web server and your php have allready forgotten about
you.


You are wrong. Counterexample available at
<http://www-etsi2.ugr.es/web/buscapersonas.php3>.

"stateless" means that the server is aware of the client only during the
request-response time, but the rest of the time the client is disconnected.

What the original post requests is a way to make the client update the
webpage in the middle of the response, when the connection is still
established and data is flowing from the server. This is perfectly
possible, if the browser is capable.

You *may* be able to do something using a http refresh in the <head> of
the page e.g.

page1.php:
echo '
<head>
<META HTTP-EQUIV=Refresh CONTENT="10; URL=http:page2.php">
</head>
<body>
AAA<br>
';

page2.php:
echo 'BBB<br>';

I think that the original post doesn't want this.
Jul 17 '05 #5

Dani CS wrote:
Sacs wrote:
yawnmoth wrote:
<snip>

You are wrong. Counterexample available at
<http://www-etsi2.ugr.es/web/buscapersonas.php3>.


another counter example:

http://www.proxyelite.org/phpBB2/proxy_list_check.php

also, how would a browser be able to distinguish between a slow server
or a really big webpage and one that has simply run the sleep command?
the first two don't require the whole page be loaded before it displays
any part of it, so why should it do so when i use sleep?
What the original post requests is a way to make the client update the webpage in the middle of the response, when the connection is still
established and data is flowing from the server.

yup - that's exactly what i'm wanting to know :)

Jul 17 '05 #6
Dani CS wrote:
You are wrong.


Ok, I sit corrected. I blame the mother of all hangovers, my brain
isn't exactly engaged at the moment...

:-)
Jul 17 '05 #7
"yawnmoth" <te*******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>';
flush();
sleep(10);
echo 'BBB';
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>';
ob_flush();
flush();
sleep(10);
echo 'BBB';
?>

any help would be appreciated - thanks!


All browsers buffer incoming data. Rendering will only happen after a
certain amount of data has been read (usually a few Ks). If a browser redraw
the page with every few bytes of data then your screen would constantly
flicker.

To make the browser update the page, send a bunch of comment tags after the
actual contents:

echo str_repeat("<!-- Agent Smith -->", 1000);

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Bridge | last post by:
Is there any way to get Internet explorer to treat a text/plain .net page as plain text using asp.net? It seems like IE doesn't trust text/plain as a mime type, and so it (ironically) displays it...
3
by: Bala | last post by:
Hi, In my page there is 4 dropdown list boxes.when page loading that time i am loading the nearly 3000 items array. so its taking too much time to load. is it other way fill up the dropdown...
3
by: HK guy | last post by:
How to write a program that can check the web page loading time? Before I have written a browser that use IE as the core, but it does not support frame. Since the documentcomplete event will...
6
by: Coleen | last post by:
Hi all :-) I need to redirect to multiple pages on click of a transmit button, without redisplaying each page. This redirection is to capture session variables that are created on each page and...
0
by: tony | last post by:
I am working on a PHP project and having a partial page loading problem randomly. The PHP module 4.4.0 is running on apache server 1.3.33, with database connection to oracle 10g. The problem...
1
by: kelvinweb | last post by:
Hi All, How to calculate web page loading time on client and send back result to server side ? Urgent ! Thanks alot !
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.