mardi 11 avril 2017

How to imitate AJAX-like behavior in Rails app, but initiate request from the server?

I have a Rails app in which I have created a series of filters for the user to click (checkboxes). When the user clicks them, I want to initiate a request to a server and update the data displayed.

I have currently implemented this with client-side Javascript. I listen for the change in the filters, and initiate an AJAX request to the server. When the data comes back, I just update the HTML directly.

However, I would now like the request to come from the Rails app, so that I can ensure that only authorized requests are made to the database.

How can I simulate this same behavior: listening to the change-events on the UI-widgets; making a request; and updating the page in-place, while initiating the request from the server?

Aucun commentaire:

Enregistrer un commentaire