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
Asked
Active
Viewed 4,867 times
3
-
It is possible.....Short Question and what all you get is Such a Short Answer – Salil Sep 02 '13 at 07:45
-
If you don't mind, would you tell me how? or just give a hint. because I spent hours looking for it and got nothing. thank you – ishwr Sep 02 '13 at 07:47
-
it depends on your requirement.....though Ajax is Best way to do it – Salil Sep 02 '13 at 07:49
-
1Check this http://stackoverflow.com/questions/5933261/how-to-call-a-rails-method-from-in-jquery. This answers your question. – Bhagyashree Sep 02 '13 at 09:21
1 Answers
1
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.

Community
- 1
- 1

ScottJShea
- 7,041
- 11
- 44
- 67