Problem With Periodicalupdater Updating Tree

I am stuck on trying to get a treeview to update on a timer. The alert happens on changes from the jquery, but the div update never seems to happen. Not sure what is going on, and out of ideas. THX

//View

$(document).ready(function(){

$.PeriodicalUpdater( "<?php echo $url ?>",{        


    'method' : 'post',


    'data' : '',


    'maxTimeout' : 1000,


    'minTimeout' : 2000,


    'multiplier' : 2,


    'maxCalls' : 0,


    'autoStop' : 0,


    'type' : 'json',


    'cookie' : {}


    },


    function(remoteData, success, xhr, handle){


            $("#treeview");


             alert("got here");


     });

});

</script>

<div id="treeview">

<?php

$this->renderPartial(’/site/_tree’, array(‘treeData’=>$treeData),false,true);

?>

</div>

//Controller

public function actionTekManagerRefresh(){

    &#036;model = new TekManagerForm();


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


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


    &#036;this.partialRender('/site/_tree',&#036;treeData,false,true);


   }

//_tree.php

<h3>Project</h3>

<?php

// $connection=Yii::app()->db;

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


    'id'=&gt;'tree',


    'data'=&gt;&#036;treeData,


 //   'url' =&gt; array('FillProjectTree'),


    //'collapsed'=&gt;false,


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

);

?>

Hi jautry

  1. Try not to open new threads for the same issue. Otherwise we can’t see the previous replies to your problem.

  2. Your controller has partialRender instead of renderPartial; and the $treeData is not passed in an array. Are these just typo’s?

  3. It is very difficult to know what you are doing without more info:

3.1 Try this function:


function update_tree($url)

{	

	try{

		var request = $.ajax({ 

		  url: $url,

		  type: "GET",

		  cache: false,

		  dataType: "html" 

		});

		

		request.done(function(response) { 

			$('#treeview').html(response);

			request = null;

		});

		

		request.error(function(jqXHR, status, error){

			alert (error + ": " + jqXHR.responseText);

			request = null;

		});

		

	}

	catch(error){

		request = null;

		alert(error.message + '. ' + 'Please contact us.');

		return false;

	}

}

3.2 Or else, this is what I am doing:

My tree is inside an iframe.

When I want to update my tree I do this in a js function: $(’#iframe1’).attr(“src”, $url);

This reloads the iframe’s source. The $url points to my controller action that rendered the entire view in the first place. So each time the entire view is replaced - not just the <div id=“treeview”>.

Note that the code ‘in the iframe’ uses different js than the code ‘underneath the iframe’. Take a look at this wiki. If you don’t want to use the dialog, you can just use the iframe.

Regards