Invoke javascript function when data is ready (in ERB view)?

Note that the function in the head must also be inside -tags.

Thanks, although I just realized that when I use: render :json => @data in my controller, Firefox 3 wants to open the page as a file because the content-type is application/json. – codecraig Mar 1 at 11:54 You can also render the data as JSON directly in the view inside the function if you want. – WTP Mar 1 at 13:24.

Since Firefox 3 can't handle a content-type of application/json (i.e. It wants to download it as a file, it won't open it natively) I had to do something else. My controller has two methods: def foo end def foo_json # get data and render json render :json => @data end My view now has an empty which will store the JSON once I do something with it.

I used: $(document). Ready(function() { $. GetJSON(....) }); to populate my div when the page loads which works great.

Thanks Radek for your suggestion.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions