Showing posts with label Running Digital Clock. Show all posts
Showing posts with label Running Digital Clock. Show all posts

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}"
end


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!! =)