I am trying to display the data of each value and the graph using d3js on the index page, but if I write it like below,
on page display and json loading during graph drawing
@foo processing to create the data.
After displaying html, @foo has the data, so how can I use it as it is for graph drawing?
def index
@hoge=...
@foo=@hoge....
response_to do | format |
format.html
format.json {render:json=>@foo}
end
end
ruby-on-rails json
Basically, you can only respond once to a single request.
Two requests and responses are required.For example, here, two endpoints are required.
By all means
If that's the case, I think it's better to use volatile cache to make @foo in one time for these two requests.Keep it in memory for a certain amount of time.
Or, if HTML also shows the contents of @foo, one way is to stop ajax.
© 2024 OneMinuteCode. All rights reserved.