Note: This will only work on IPhone,Android and Blackberry(version 6 and above)
In this example I will load some text inside a div on clicking of a button.
Step 1.) Create a div and button on a page
<input type= "button" id="some-button"/ name="button" value="Load Value By Ajax">
<div id= "some-div">
</div>
Step 2.) Create a Javascript
Step 3.) Create a action ajax_method in controller
def ajax_method
@some_value = "Its all about ruby ---" +@params['some_variable']
render :action => :ajax_method, :layout => false, :use_layout_on_ajax => false
end
Step 4.) Create a ajax_method.erb file
<i><b><%= @some_value %></b></i>
It is just a very basic example you can do many more things like error handling, adding loading image etc.
This comment has been removed by the author.
ReplyDelete