0

I am looking for a way to update ruby global variables in javascript.

Say I have two values defined: <%@value1=[]%> <%@value2=[]%>, both equal to blank arrays. How can I updates these array using javascript?

Thank you. Please let me know if I wasn't clear enough.

3
  • update ruby global variables in javascript - i believe there is no way to do it. <%@value1=[]%> compiled on the server to the js code. You cant update it on the client side. Commented Aug 28, 2015 at 20:29
  • How would I go along to update a table bassed on what is selected by the user in input. Is there any other way to do this? Commented Aug 28, 2015 at 20:31
  • It is absolutely impossible to update server-side variables with client-side code. They code rendered to the client Commented Aug 28, 2015 at 20:41

1 Answer 1

1

I would use AJAX to hit the server with your new value and change the ruby (server) value there.

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

1 Comment

And here. w3schools.com/jquery/ajax_ajax.asp. Just google Ajax jquery examples and try some of the example code. IF you use the google chrome browser you can view the request in your developer tools. There you can see the request sent to the server and what the server responded with. Hope that Helps!

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.