Hi all. 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 28, 4:46 pm, William Haigh <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all. > > 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> Thanks > -- > Posted viahttp://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> 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 actionAlso note that the Rails helper is a thin wrapper around Prototype''s Ajax.PeriodicalUpdater. http://api.prototypejs.org/ajax/ajax/periodicalupdater/ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> On Apr 28, 4:46�pm, William Haigh <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Hi all. >> >> 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 > > FredWould 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> <%=periodically_call_remote(:url => ''status'', :frequency => ''5'', :update => ''.info2'')%> <%else if @collectorstatus == FALSE%> <div class="error">Network Log Collector Is Offline!</div> <%else%> <%end%> <%end%> <%end%> <% content_for :content do %> <% if @collectorstatus == TRUE%> <div id="gauges2"> <% visualization "ProcessorGauge", "Gauge", :width =>500, :height =>200, :redFrom => 90, :redTo=> 100, :yellowFrom=>80, :yellowTo=> 90, :minorTicks=> 5, :html => {:class => "gauge"} do |chart| %> <% chart.string "Name" %> <% chart.number "Values" %> <% chart.add_rows([ ["Processor ",@processorusage], ["Mem Used ",@memoryint] ]) %> <% end %> <% end %> </div> <%end%> [/code] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.