Update Progress Bar

Hi,

I am curious to find out if the code below is a good way to update a progress bar. I am using YiiStrap for the nifty looking stuff. Is there any way to call a controller doing the same? Would that be the best way?

stuff below goes into a view





echo TbHtml::stripedProgressBar(0);

$totalstufftodo = 500000;

$total = 100/$totalstufftodo;


for ($i = 1; $i <= 100; $i = $i + ceil($total) ) {

   echo ' <script type="text/javascript">  

   $(".bar").css({"width" : "' . ceil($i) . '% "});

   </script>';

   flush();

   }