Reputation: 3189
I am trying to get a list of recent items every 5 seconds. The list has to be rendered on every view under that controller. What is a best approach to get it done in rails3? Something like a ticker. Any got a great solution/example for this?
So I am trying these three javascripts I found on discussion forums. and none of them generating any requests to the server. Any idea why?
$(document).ready(
function(){
setInterval(function(){
$('#item_list').load('/item/item_list');
}, 3000);
});
$(document).ready(function worker() {
$.ajax({
url: '/item/item_list',
success: function(data) {
$('#item_list').html(data);
},
complete: function() {
setTimeout(worker, 500);
}
})();
function startTimer()
{
new Ajax.PeriodicalUpdater('#item_list', '/item/item_list', {
method: 'get', frequency: 3, decay: 2
});
}();
$(document).ready(startTimer(););
Upvotes: 0
Views: 354
Reputation: 10885
I have answer similar like this please check at this URL.
Show current time on page in real ticks format using Rails
Upvotes: 1