|
-
Feb 13th, 2006, 09:35 AM
#1
Thread Starter
Addicted Member
withou Reloading
I am currently not able to figure out how it will be coded.
*Problem*
Main page where user will enter some data and click "calculation" button.And the page will be submitted to calculations.php .
calculations.php will output 10 results and usually takes 6 seconds for each result.In total it will take 60 seconds to calculate and show the results.
But i want to do some tricky work so that as soon as each result is calculated user should be able to see the result.But it should be without reloads of page.
I need your help to code this trick.
Thank You.
-
Feb 13th, 2006, 09:56 AM
#2
<?="Moderator"?>
Re: withou Reloading
There is a function called flush() which pushes the current buffer to the browser. How ever you also may need to call ob_flush().
If you want to be able to manipulate the buffer output then look into the output control functions
http://uk2.php.net/manual/en/ref.outcontrol.php
-
Feb 15th, 2006, 06:15 AM
#3
Thread Starter
Addicted Member
Re: withou Reloading
Code:
<?
echo("first <br>");
flush();
sleep(5);
echo("second <br>");
flush();
sleep(5);
echo("third");
?>
Its not working as intended
Last edited by slice; Feb 15th, 2006 at 06:23 AM.
-
Feb 15th, 2006, 12:20 PM
#4
Re: withou Reloading
By default, output is sent to the browser as an when. If you want control over when it is sent you need to use ob_start() and ob_flush():
PHP Code:
<?php
ob_start();
echo("first <br>");
ob_flush();
sleep(5);
echo("second <br>");
ob_flush();
sleep(5);
echo("third");
?>
-
Feb 15th, 2006, 12:58 PM
#5
Thread Starter
Addicted Member
Re: withou Reloading
It's not working all the output is displayed after 10 seconds.Not as i want to do
First
then after 5 seconds
Second
then after 5 seconds
Third
In that way...
-
Feb 15th, 2006, 01:54 PM
#6
Re: withou Reloading
Which version of PHP are you using?
-
Feb 15th, 2006, 01:56 PM
#7
Re: withou Reloading
Also, look at this from the docs page:
jeremy at e2-media dot co dot nz
26-May-2005 12:09
we had problems with flushing data to the browser. a simple call to ob_flush() or flush() would not work. We found that repeatly calling theses fuctions did work however.
<?
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
?>
go figure!
-
Feb 15th, 2006, 02:32 PM
#8
Thread Starter
Addicted Member
Re: withou Reloading
Not working
Code:
ob_start();
echo("first <br>");
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
sleep(5);
echo("second <br>");
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
sleep(5);
echo("third");
?>
Php 4.3.10
-
Feb 15th, 2006, 02:46 PM
#9
Re: withou Reloading
Using the code I posted in #4, this is what I get.
http://adam.codedv.com/examples/ob_test.php
Also, if you look at the code above, flush is only being used after ob_flush.
-
Feb 15th, 2006, 02:59 PM
#10
Thread Starter
Addicted Member
Re: withou Reloading
Its exactly working as i want.But what's problem with my code or php ?
-
Feb 15th, 2006, 03:18 PM
#11
Re: withou Reloading
Your web host may be buffering the reponse; this is all I can think of. Do you happen to know what web server they use?
-
Feb 16th, 2006, 12:28 AM
#12
Thread Starter
Addicted Member
Re: withou Reloading
I am testing it on my local host pc
-
Feb 16th, 2006, 04:03 AM
#13
Re: withou Reloading
Which web server software are you using?
-
Feb 16th, 2006, 08:14 AM
#14
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|