I’ve made a basic shoutbox in Yii and everything works great. It’s set to refresh every 10 seconds through ajax and this works great too, but if I click on another page when it’s loading (when the little spinner is there) then a blank javascript alert appears, the other page loads and the alert goes, but I don’t know where it’s coming from, it’s not in my code. Firebug doesn’t give any errors, any help would really be appreciated.
This is the refresh code:
<script type="text/javascript">
$(function() {
function callAjax(){
$.fn.yiiListView.update('Shoutbox');
return false;
}
setInterval(callAjax, 10000 );
});
</script>
and this is the list view:
<?php $this->widget('zii.widgets.CListView', array(
'id' => 'Shoutbox',
'dataProvider'=>$dataProvider,
'itemView'=>'shoutbox.views.shoutbox._view',
#'afterAjaxUpdate'=>'js:function(id, data) {$("abbr.timeago").timeago();}', //for ajax update
'summaryText' => '',
'emptyText' => '',
)); ?>
I’ve tried putting return: false; in the refresh but it didn’t work and I commented out the afterAjaxUpdate but it still happens.
Ok, hopefully this will eventually help someone else.
In the Yii framework (version 1.1.12) open up file:
Find line 117:
Comment out the alert, problem solved!
It looks like because the request was getting interrupted Yii throws an error which makes perfect sense but the blank alert was annoying.
Also remember to clear out your assets folder and browser cache after changing the file.