开发者

Rails : please wait.. report generating page

开发者 https://www.devze.com 2023-03-20 18:17 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号