CodeIgniter Forums
flush(); 'ing data in a view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: flush(); 'ing data in a view (/showthread.php?tid=32646)



flush(); 'ing data in a view - El Forum - 07-29-2010

[eluser]Falney[/eluser]
Hi. I'm having a problem where I need to flush data in a view file to create a div based progress bar.

I need the script to do a lot of HTTPRequest's and I need some way to show people that the site isn't actually broken.

Unfortunately (And Im not 100% sure why though but I think I may know) flush(); doesn't seem to want to work. Here's a (very)basic test script I wrote up while trying to get it working;

Code:
<?PHP
ob_start();
echo 'Bounty<br>';
@ob_flush();
sleep(5);
echo 'Snickers<br>';
@ob_flush();
sleep(5);
echo 'Mars';
flush();

//END OF TEST VIEW

It's running the whole script and outputting it at once when it's finished processing.

I've tried using ob_get_contents() also. I'm just at a loss and feeling embarressed from it.

Please help.

Fal


flush(); 'ing data in a view - El Forum - 07-29-2010

[eluser]jkevinburton[/eluser]
it doesn't work because you cannot use flush() as the whole output of views are buffered then spit out.


flush(); 'ing data in a view - El Forum - 07-29-2010

[eluser]Falney[/eluser]
Can you suggest an alternative method? Or should I just flush an aditional view above the one doing the process with a message or repeating loading animation?

Edit~

Infact. I cant get flush to work in a controler either

Code:
ob_start();
$this->load->view('includes/headder');
ob_flush();
$this->load->view('syndicates/send', $results);
$this->load->view('includes/footer');