Ok, so I have a model called room and a roomController. I also have a room view folder with the following view files
-
login
-
room
-
moderatorRoom
when users login using the login view, the login action in the roomController is called and they are redirected to one of the 2 rooms, room OR moderatorRoom. In both these view files a list of all users in that room is displayed. Below is the code for the div displaying all users in the room.
<div id=logged_in_users_list>
<p id="userList">
<?php
if(isset($allUsers))
{
foreach($allUsers as $person_in_the_room)
{
if($person_in_the_room->has_voted==0)
{
echo $person_in_the_room->username.'<br/>';
}
else
{
if(isset($poll))
{
if($poll->before_settings == 'Voter only')
{
echo $person_in_the_room->username.' '.'<br/>'; // code here for adding vote result beside their name
}
else
{
echo $person_in_the_room->username.' '.CHtml::image(Yii::app()->request->baseUrl.'\images\icon_tick_green.gif').'<br/>';
}
}
}
}
}
?>
</p>
</div>
What I’d like to know how to do is, how could I write an ajax function to update/refresh this div every time a user logs in? I’m new to yii and php, and even newer to javascript so help is both greatly needed and appreciated. If someone was kind enough a simple code example snippet would be amazing!