Im using ROR and am trying to get some data from a database into a web
page then periodically update this information say every 5 seconds. Ive
got the content working statically and have the div refreshing at
intervals, the only problem now is passing that new information from the
database into the variable.I guess I have to use AJAX for this. Anyone
got any ideas?
Thanks
Im using ROR and am trying to get some data from a database into a web
page then periodically update this information say every 5 seconds. Ive
got the content working statically and have the div refreshing at
intervals, the only problem now is passing that new information from the
database into the variable.I guess I have to use AJAX for this. Anyone
got any ideas?
Rails has a helper (periodically_call_remote) that will generate
javascript that calls an action at the specified interval and updates
the specified div with whatever is rendered by the action
Rails has a helper (periodically_call_remote) that will generate
javascript that calls an action at the specified interval and updates
the specified div with whatever is rendered by the action
Also note that the Rails helper is a thin wrapper around Prototype's
Ajax.PeriodicalUpdater.
Im using ROR and am trying to get some data from a database into a web
page then periodically update this information say every 5 seconds. Ive
got the content working statically and �have the div refreshing at
intervals, the only problem now is passing that new information from the
database into the variable.I guess I have to use AJAX for this. Anyone
got any ideas?
Rails has a helper (periodically_call_remote) that will generate
javascript that calls an action at the specified interval and updates
the specified div with whatever is rendered by the action
Fred
Would you be able to take a look at the code below. Ive done what you've
suggested and from the Rails console I can see that the data is been
queried at a regular interval and the div is refreshing but the new data
is not being inserted. FYI the value of @uptime is taken from an SNMP
query in the controller.
Thanks
[code]
<% content_for :subtitle do %>Log Collector Server Status<%end%> <p></p>
<% content_for :error do %>
<%=javascript_include_tag 'application'%>
<%=javascript_include_tag 'prototype'%>
<% if @collectorstatus == TRUE%>
<div class="success">Network Log Collector Is Online</div>
<div class="info">IP: 192.168.1.204</div>
<div class="info2">Uptime: <%=@uptime%></div>
<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script>
var auto_refresh = setInterval(
function()
{
$('.info2').fadeOut('fast').fadeIn("fast");
}, 1);
</script>