Jump to content

is there a way to send info to a browser during a loop?


ballhogjoni

Recommended Posts

yep I tried that too. It didn't work...I am using firefox, would that be why?

 

Well a loop of 10 would not really show this. It works in Firefox cause that is what I use and I know it works...try this.

 

<?php
set_time_limit(100);
for($i=0;$i<=10;$i++){
    echo 'this is something '.$i;
    ob_flush();
    flush();
    sleep(5);
}
?>

 

It should take display that every 5 seconds.

 

Along with the browser difference, I know that some Anti-virus software will hold your page buffer until the end then display it, so that is also something to think about/check.

 

 

Php, different web servers and different web server settings for buffering and compression, and different browsers and different browser settings for compression affect if and when you can incrementally send output from a server to a browser.

 

You should not expect a web based application to be able to do this from the server side. If you get it working on one setup, it probably won't work on the next.

 

To get a value to update in the browser, you should have the browser get that value from the server using AJAX.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.