Ajax on Railsのサンプル
ONLamp.com: Ajax on Rails
http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html
<html> <head> <title>Ajax Demo</title> <%= javascript_include_tag "prototype" %> </head> <body> <h1>What time is it?</h1> <div id="time_div"> I don't have the time, but <%= link_to_remote( "click_here", :update => "time_div", :url =>{ :action => :say_when }, :position => "after" ) %> and I will look it up. </div> </body> </html>
これがブラウザにどうわたるかというと
<html> <head> <title>Ajax Demo</title> <script src="/javascripts/prototype.js" type="text/javascript"></script> </head> <body> <h1>What time is it?</h1> <div id="time_div"> I don't have the time, but <a href="#" onclick="new Ajax.Updater('time_div', '/friends/say_when', {asynchronous:true, evalScripts:true, insertion:Insertion.After}); return false;">click_here</a> and I will look it up. </div> </body> </html>
こんなかんじ
括弧の使い分けかたがよくわからないが、まぁなんとか