Ruby on Rails
<html> <head> <title>Ajax Demo</title> <!-- tell rails to include prototype.js --> <%= javascript_include_tag "prototype" %> </head> <body> <h1>What time is it?</h1> <div id="time_div"> I don't have the time, but <!-- Create a link which calls the server-side action /say-when --> <!-- and then updates the "time_div" div with the results --> <%= link_to_remote( "click here", :update => "time_div", :url =>{ :action => :say_when }) %> and I will look it up. </div> </body> </html>
class DemoController < ApplicationController def index end def say_when render_text "<p>The time is <b>" + DateTime.now.to_s + "</b></p>" end end
:position => "after"
14 of 16