You are here: Home Blog How to show loading image while making AJAX request?

How to show loading image while making AJAX request?

E-mail Print PDF

JavaScript Tools

This is a JavaScript class that you can use to blur parts of the page. You are able to put fog on the entire page. You can also darken individual elements.

I use it to show loading image while perform AJAX request.

Loading page

How does this work?

  1. Load the JS class and CSS style by putting the code that follows, into the "head" tag of the document.
  2. <script src="/itpoverlay.js" type="text/javascript"></script>

    <link href="/style.css" type="text/css" rel="stylesheet" />

  3. Put the id of the element that you want to overlay. It is necessary because the class gets the element by id, and you will have to set it.
  4. <body id="body_id">
  5. Create an object by specifying the id of the element on which you wish to darken. In this case, I darken the body tag, and it will hide the page.
  6. <script>

    var overlay = new ItpOverlay("body_id");

    overlay.show();

    </script>

By show() you put overlay on the element. To remove it must use the method hide().

Demo

On the demo page, you will find several ways for using. You will see how to use it with AJAX request and full page overlaying.

Download

Attachments:
Download this file (itpoverlay.zip)ITPOverlay.zip[JavaScript class and examples]11 Kb

Subscribe via RSS or Email:

Share this post

 

Add comment


Security code
Refresh

Free Subscription

You can get the latest publication via RSS, Twitter or Facebook. And I can also deliver last posts to you for free via Email:

 
RSS subscription Find us on Facebook Google+ page Follow me