Rails : please wait.. report generating page
i am generating report in my application. it takes 10 to 20 seconds to load the page completely. i need a page between these pages to show message like "Generating Report.. Please Wait.." and also i give some useful ti开发者_开发知识库p instead of simply waiting.
how to do this with rails? anyone have idea?
You have a couple of options. The easiest one would be to do an Ajax call for the report page: before triggering the ajax call, you would display the "Please wait..." message and whatever other texts you might want the users to see while they're waiting, and on successful completion of the call you would replace the contents of the page with the report.
The other option is to use a background job queue, like Joel AZEMAR suggested: you trigger the report generation (which you would do in a background job) and return immediately, rendering a "Please wait..." page with all the tips; on the same page you add a Javascript polling mechanism to query the server from time to time for the results of the report generation.
I would recommend to try the first one unless the report is really CPU/memory intensive or time consuming.
精彩评论