Reputation: 13558
I run Ruby threads that use PhantomJS, a command-line headless Webkit engine, to turn a number of urls into images. As of now, the page loads only once all of the images have been generated. Instead, I want to load the page and have a loading animation while the images are generated and show them as they are generated without the user having to reload the page. How would I do this? (I assume AJAX is needed.)
Upvotes: 0
Views: 331
Reputation: 35318
You need to process them in a separate process. Once your request is finished, you lose a reference to the Threads that you started, so you can't just contact them again to ask for a progress report. I guess you could have the Threads write the result to the database once done, but there are better alternatives.
Resque-status is a gem that extends Resque by allowing you to track the status of individual jobs. You queue the jobs and take their job IDs, then you can use AJAX to call back to the application and query the progress of those jobs.
Upvotes: 1
Reputation:
Well, you could preload the images in the background, which would load up the page entirely while the images download.
more info: link
Upvotes: 0