Answer the question
In order to leave comments, you need to log in
How to make ajax render js response in Ruby On Rails?
There is a div element, when I click on it, an ajax request to the controller is triggered, which in turn should return a response in js format (replace the contents of the block). As a result, he returns the answer to me with html markup. And I want the behavior of the link_to helper, only in my case with a div, so that I click on the block, then the controller call, then the response in js format, which is to change the text inside the block. Do not tell me how to do everything right?
Answer the question
In order to leave comments, you need to log in
You need to use the helper like this:
In the controller of the corresponding action:
respond_to do |format|
format.js { render :layout => false}
end
Thanks for answers. How does format.js work? Renders a certain .js file in the view and gives the generated page to the client, or does it give the javascript code that is in the view to the client, and he executes it on his side?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question