开发者

Loading... image status

开发者 https://www.devze.com 2023-02-22 13:02 出处:网络
The website is build with Codeigniter MVC framework. I have a page that is taking longer to load (about 20 seconds) due to the nature of the query and the large database size.

The website is build with Codeigniter MVC framework.

I have a page that is taking longer to load (about 20 seconds) due to the nature of the query and the large database size.

Is there a way I can show a 'Loading...' gif image as the view is getting开发者_JS百科 loaded? Looking for an example using codeigniter.

Thanks


Typcial ajax loaders are accomplished with javascript. Basically, the first thing your click handler does is show the animated gif then executes the javascript command to load the new content into the page. There's really no codeigniter involved.

Here's a link to a page exhibiting a way to do this with jquery.

To summarize:

$(document).ready(function(){
    $('.your_button').click(function(){
        //show your loader gif (recommend loading and hiding with css
        $('#new_content img.ajax_loader').show();
        //where you'll load the page
        $.post(href,{data},function(new_data){
            $('#new_content').html(new_data);
        });
});


Use jQuery BlockUI plugin


Here's an idea of how to do it (not entirely) with Javascript:

  1. Register the query that the user would like executed
  2. Place the query in a queue in the database with the status: pending
  3. Redirect the user to a page with your loading gif on it, constantly polling another page with AJAX capable of checking the status of the query in your queue returning a URL to the query results when it's complete
  4. Have a separate program work it's way through the queue, setting the status of the query to complete and caching the results in the table
0

精彩评论

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