Tuesday, February 23, 2010

Ruby on Rails : Ajax : Running Digital Clock

Step 1: view.rhtml
<%= javascript_include_tag "prototype" %>
<h1>Test periodically_call_remote</h1>
<div id='show_date_time_id' style="background-color: #eee"></div>
<%= periodically_call_remote(:update => 'show_date_time_id',:url =>
{ :action => :show_date_time },
:frequency => 1 )%>

Step 2: ajax_controller.rb
def show_date_time
render :text=>"Now : #{DateTime.now.to_s}"

If you find this useful, would you like to buy me a drink? No matter more or less, it will be an encouragement for me to go further. Thanks in advance!! =)


  1. http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/periodically_call_remote

    periodically_call_remote is deprecated

  2. This is an amazing blog,it gives very helpful messages to us.Besides that Wisen has established as Best Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry

  3. Really nice blog post.provided a helpful information.I hope that you will post more updates like this Ruby on Rails Online Course Hyderabad