I want to upload and then process a file in a Ruby on Rails app. The file upload is usually quite short, but the server-side processing can take some time (more than 20 seconds) so I want to give the user some indicator - something better than a meaningless 'processing...' screen.
I'm trying to use the following code in the view
<%= periodically_call_remote(:url => {:action => 'progress_monitor', :controller => 'files'},
:frequency => '5',
:update => "setProgress('progressBar','5')"
) %>
The content of the :update parameter is the javascript I want to run every 5 seconds
and the following code is in the files controller
def progress_monitor
render :text => 'whatever'
end
Eventually the progress_monitor method will return the current progress as an integer (% complete) and that will be passed into the 'setProgress' javascript code (that will update an on screen element)
However, I'm struggling to get a correct response from from the server that can then be passed into javascript.
Can anyone help, or am I approaching this the wrong way?
There is a follow up question to this, I originally updated this question but the update was sufficiently different to warrant a new question, here.