how to reload an new page automatically when an event is occured

hi lets say i have a groups page when i join that group it should not reload but only the contents are loaded dynamically such as before joining i cann’t post on it but as soon i hit the join btn and it is confirmed then the whole page is not reloaded but lets say posting pannel is now visible to me

or lets say i have homepage and when any one sent a PM to me my page should be able to detect that PM and show the notification

can it be possible in yii, if then HOW ?

To update part of the page you use jQuery… to get the data to be displayed you use ajax…

thanx i m on it

Just recently I worked on something similar…

all users in our company has the homepage set to the company main intranet page…

on that page there is a section with recent INFO and NEWS that I wanted to be updated as soon as someone enters a new record in the database…

The main code that does that is this




  Yii::app()->getClientScript()->registerScript("myinit1","

 	setInterval('$.updateData()',600000);	// .. refresh every 6 min.

  ");


  Yii::app()->getClientScript()->registerScript("myinit2","

 	$.updateData=function () {

 		$.ajax({

 			'success':function(data) {

 				$('#recentdata').html( $('#recentdata',data).html() );

 			}

 		});

 	}

  ",CClientScript::POS_END);



Basicaly the first part sets that the function updateData() is called every 6 minutes…

The function does an ajax call that reloads the same page… then it gets just the html content of #recentdata DIV and replaces the current one on the page…

Note that the best solution would be to make an ajax call that would output just the needed data not the entire page…