I want to download and then process the file in a Ruby on Rails application. The file upload is usually quite short, but server-side processing may take some time (more than 20 seconds), so I want to give the user some kind of indicator - something is better than the meaningless "processing ..." screen.
I am trying to use the following code in a view
<%= periodically_call_remote(:url => {:action => 'progress_monitor', :controller => 'files'}, :frequency => '5', :update => "setProgress('progressBar','5')" ) %>
Parameter contents: update is javascript that I want to run every 5 seconds.
and the following code is in the file controller
def progress_monitor render :text => 'whatever' end
In the end, the progress_monitor method will return the current progress as an integer (% complete) and will be passed to javascript 'setProgress' code (which will update the item on the screen)
However, I am struggling to get the correct response from the server, which can then be passed to javascript.
Can someone help, or am I approaching this wrong?
I have the following question: I originally updated this question, but the update was varied enough to guarantee a new question here .
source share