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

4 comments:

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

    periodically_call_remote is deprecated

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  4. Many JavaScript training programs are powered by Blogger to provide easy access to tutorials, coding exercises, project updates, and learning resources. TypeScript TrainingBlogger offers a simple platform where instructors can publish lessons, share sample code, and communicate with students through regular posts. By combining practical projects with online learning materials, JavaScript training powered by Blogger creates an accessible and effective environment for beginners and aspiring web developers.

    ReplyDelete