Proper Ajax Div Refresh Methodolgy

I am using an ajax timer to refresh screen data. It appears, however, that the bitmaps get overdrawn instead of redrawn causing additional memory to get consumed at every refresh. I am just trying to find out what the proper method of doing this would be to get around this issue.

<?php

$url = Yii::app()->createUrl(‘tekmanager/tekmanagerrefresh’);

?>

—Timer Function

<script type="text/javascript">

timeout = 5000;

function refresh(){

<?php

echo CHtml::ajax(array(


            'url'=&gt;&#036;url,


            'type'=&gt;'post',


            'update'=&gt;'#tree',


            'data'=&gt;array('view'=&gt;'js:jQuery(&quot;#id_viewList&quot;).val()'),


            ))

?>

}

$(window).load(function(){

window.setInterval("refresh()",timeout);

});

</script>

—Controller Refresh function—

public function actionTekManagerRefresh(){


    &#036;model = new TekManagerForm();


    &#036;data = &#036;model-&gt;getTreeData();


    &#036;data['treeData'] = &#036;this-&gt;getDataFormatted(&#036;data['Campus'],0);


    &#036;view = &#036;_POST['view'];


    &#036;data['view'] = &#036;view;


    &#036;data['gridData'] = &#036;model-&gt;getViewData(&#036;view,'ALL'); 


    &#036;this-&gt;renderPartial('/site/_tree', array('refreshData'=&gt;&#036;data), false, true);


    }

—/site/_tree.php—

<h3>Project</h3>

<?php

  &#036;this-&gt;widget('CTreeView', array(


    'id'=&gt;'tree',


    'data'=&gt;&#036;refreshData['treeData'],


    'collapsed'=&gt;false,


    'htmlOptions'=&gt;array( 'class'=&gt;'treeview-black','href'=&gt;'#')) 


    );   


    


    &#036;arrayDataProvider=new CArrayDataProvider(&#036;refreshData['gridData']['viewData'], array( 


        'id'=&gt;'id',


        'pagination'=&gt;array( 


        'pageSize'=&gt;10, 


        ), 


   )); 

$this->widget(‘zii.widgets.grid.CGridView’,

    array(


        'id'=&gt;'view',


        'dataProvider'=&gt;&#036;arrayDataProvider,


        'columns'=&gt;&#036;refreshData['gridData']['columnData'],


         ));           

?>

Looking at this further, I think I should be doing some kind of refresh or update on the widgets. Reloading the widgets seems to just duplicate them in memory.