Reading data from file and passing to javascript

I am new to ruby.
Could someone help me in reading data from a CSV file, storing the
integers in an array, and passing this to a JS function?

ruby executes on the server side, which is the place on the internet
that is hosting your website. js executes on the client side, which
is someone’s browser. In other words, the two languages execute
at different times and miles apart from each other. So you aren’t going
to be able to pass ruby arrays to a js function.

The way the internet works is: someone’s browser requests information
from a certain website. The server that is hosting that website
receives the request, and if the request asks that a ruby script be
executed, the server will first execute the ruby script before sending
back the requested information in what is called a response. All
information that is passed back and forth between browsers and servers
in requests and responses is in the form of a string.

js executes in the user’s browser in response to the user doing
something on the web page, like clicking on a button, or mousing over
some text. There are ways to have js send a request to the server for
some information while the web page is doing other things. Those js
requests are called HttpXMLRequests or AJAX. If you are new to web
programming, those topics are going to be beyond your abilities at this
time.

Matthew

If you are going to use forums like this, you need to ask more
digestible questions.

Firstly we are not clear where JS comes in. Most likely it is in a web
browser session, but are you creating the JS data when you create the
web page content or are you calling Ruby later with AJAX?

Your question is too big. It currently covers reading a CSV file,
creating JS and parcelling up data to send between the two languages.
Are you expecting people to tell you how to do the whole thing? People
haven’t got all day to write your code.

For such a big question why do you introduce the rather specific concept
of an array? Have you already written the JS? Are you using something
that already exists?

You’ll get to your answer more quickly if you deal with small specific
chunks. Also in this case, set the scene with an overview of your
application.

Thanks for your consideration, but I have solved this issue myself.
I fetched the data using ruby code, then passed the array created, when
generating JS code.

Thanks anyway.