Doing AJAX with popular javascript libraries

| Basic | Prototype.js | Dojo Toolkit | Yahoo UI Library | ASP.NET | Rails |

Ruby on Rails

Let me first confess that I have only few hours of experience with ruby. And even less with Rails. But I could somehow manage to try out and put some code here. Rails like ASP.NET is a web development framework. Its becoming very popular these days. There are ways in which AJAX can be done with lesser pain in Rails. Code for simplest AJAX functionality is shown below, it resides in the *.rhtml files :
 <div id="hello_div">
      
      <%= link_to_remote( "Click  here",
                         :update => "hello_div",
                         :url =>{ :action => :say_hello }) %>
      for welcome message.
 </div>
The above code does the following for you:
  • Creates a hyperlink.
  • Executes the server side 'say_hello' function and gets the output.
  • Refreshes the contents of 'hello_div' with output.
If you are interested to see the server-side code , here it is :
class TestController< ApplicationController
   scaffold :test
  
  def index
  end

  def say_hello
    render_text "<p>Hello Geek !</p>"
  end
end
  • I am pretty sure that there are more interesting things that you can do with Rails. I'll keep this page updated with the latest I come to know.
| Basic | Prototype.js | Dojo Toolkit | Yahoo UI Library | ASP.NET | Rails |


Copyright (c) 2007-2017 Ashish Patil . Please read FAQ for more details.

comments powered by Disqus