1

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('<%= @test %>hhhhhh');

But the codes above not works... Could you help me, please, how to do?

Thank you, Manny

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.