Rails 3 and jQuery- how to transmit ruby variable to javascript
I would like to ask you - I have javascript code and I need into this part of code transmit variable with data from database. This variable is in controller. How can I do it?
I tried something like (in *.js):
$("#div").append('<%= escape_javascript(@test) %>hhhhhh');
or
$("#div").append('<%= @te开发者_运维知识库st %>hhhhhh');
But the codes above not works... Could you help me, please, how to do?
Thank you, Manny
If you are rendering a response to AJAX-call, that code should go in your_action.js.erb
file. Otherwise, if it's just inline JavaScript, place it in your_action.html.erb
under app/views/your_controller
directory.
Correct me if I understood you wrong.
精彩评论