I am trying to embed the output of Ruby code in JavaScript:
var stuff= "<% Representative.get('http://0.0.0.0:4568/') %>";
The built-in part itself works, showing the following result:
{ "name":"John Johnson", "street":"Oslo West 555", "age":33, "phone":"555 1234567"}
The line above contains the SOURCE of the EXACT PAGE; It works locally, so I can’t show you the page.
When in a variable I try to send it to my application with this:
document.getElementById("X_Axis").value=stuff.name;
through the entrance:
<input type="text" id="X_Axis" />
I get the value undefinedevery time.
I tried hard-coded the value in JavaScript, and it works fine when it is inserted, when the embedded Ruby is placed in the JavaScript variable, it always gives me the value undefined.
source
share