Sanjay Kumar
Sanjay Kumar

Reputation: 331

how do i show a progress indicator until the server responds?

I have an application in which a page takes about 1 minute to load. It is a large page with a lot of calculation and other stuff.

I want to display a progress indicator until the server gives me a reply. Does anyone have any idea for this?

Upvotes: 0

Views: 2350

Answers (4)

Roy Ling
Roy Ling

Reputation: 1632

Add a div in your page as a blanket, initially it will show and block the whole page. And hide the div in 's onload handler. This is a plain, may be not a good solution.

Upvotes: 0

magnusson
magnusson

Reputation: 153

You need to display the loader, ajax load the content and when the Ajax request completes hide the loader and show the content or simply replace the loader with the new data.

A naive implementation could look something like this and would replace the contents of #content with whatever is returned by the url /newcontent.

<div id="content">
 <img src="/path/to/loader.gif" />
</div>

<script>
 $("#content").load("/newcontent");
</script>

or in your case where it looks like you actually want to replace the entire page replace the entire body contents with:

$('body').load('newpage.html');

Upvotes: 2

Viral Shah
Viral Shah

Reputation: 2246

you can use this code while it display over the upload.

$(document).ready(function() { 
    $.blockUI();
    //load your editor here
    setTimeout(function(){
        $.unblockUI();
    }, 10000);
}); ​

Upvotes: 0

manavo
manavo

Reputation: 1899

If it takes a long time on the server to create the HTML of the page, then there's no way of showing the page with a loading message/progress indicator, and then have the content show up.

The only way I can think of is loading the page with just the loading message/progress indicator, and then making an AJAX call to actually get the content (which takes a long time to get generated).

Upvotes: 1

Related Questions