i'm using rails 4 and javascript and here's my question: i need to change the values of 3 divs using a button. The values of the divs are generated by a ruby function that came from the controller of that page. Code:
<% $number= randNumbers %>
<div id="1"><%= $number[0] %></div>
<div id="2"><%= $number[1] %></div>
<div id="3"><%= $number[2] %></div>
<button id="btn1" >Click me!</button>
Here's the ruby method
def randNumbers
n1=rand(1..10)
n2=rand(1..10)
n3=rand(1..10)
return array=[n1,n2,n3]
end
So i need to recall the ruby function to generate new random numbers everytime i click on the button "btn1" without reloading the page. I know that i have to use ajax or jquery, but i do not really know how to use it with ruby methods. Thanks for helping :D