Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: Calling controller method from javascript [closed]

Is it possible to call controller method from a javascript? I mean it's not from view(html.erb) also not from js.erb. I want to call method from .js file, which in public folder. Thank you

like image 263
ishwr Avatar asked Jul 01 '26 17:07

ishwr


1 Answers

Yes, you want to do AJAX calls. You probably want to use jquery which would be simpler than straight javascript. Here is a link to a w3schools tutorial on jquery AJAX calls. Here is another SO post with a link to a gist with some example code or you may want to Google jQuery, AJAX and Rails 3.

like image 188
ScottJShea Avatar answered Jul 04 '26 07:07

ScottJShea