If I have user interactions in my Javascript layer, can I have Javascript actions trigger Rails controller actions and pass data from Javascript to those Rails methods?
If I have user interactions in my Javascript layer, can I have Javascript actions
Share
Yes. You make asynchronous calls back to your Rails application using
XMLHttpRequest, typically through Prototype or some other Javascript library. You pass data back to the server using query parameters, much like any other request, and your application returns HTML fragments or Javascript code that is used by the browser to update the relevant parts of the page.The PrototypeHelper class is useful for generating the right stuff in the server. Ajax.Request is what you’ll use on the client.