Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:20:25+00:00 2026-06-10T00:20:25+00:00

I am using jquery ajax and i want to display loader gif image when

  • 0

I am using jquery ajax and i want to display loader gif image when ajax is working. The loader appears correctly, however when the user scrolls or resizes the window while the loader is showing the loader moves off the screen or changes in size. I would like the loader to be fixed full screen, so that even if the user scrolls, it will not disappear from view.

Here is my code of jquery

  jQuery.ajaxSetup({  
  beforeSend: function() {
     $('#loader').show();
  },
  complete: function(){     
     $('#loader').hide();
  },
  success: function() {}
});

and here is CSS of loader and its inner div

<style>
#loader
{
  background-color: #e8e8e8;
    width: 100%;
    height: auto;
    bottom: 0px;
    top: 0px;
    left: 0;
    position: absolute;
    opacity: 0.5;
    filter: progid:DXImageTransform.Microsoft.Alpha(opacity=80);
    display:none;
}
#center {
    position: absolute;
    width: 100px;
    height: 50px;
    top: 50%;
    left: 50%;
    margin-top: -25px; // margin is -0.5 * dimension
    margin-left: -50px;
    z-index:5;
}



</style>

and html is as follow

<div id="loader" >
    <div id="center">
        <img src="images/loading.gif" />
    <div>
</div>

and here you can check my test page

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:20:27+00:00Added an answer on June 10, 2026 at 12:20 am

    This is how I would roughly center the loader image both horizontally and vertically using your markup.

    body { 
         height:100%;
         margin:0;
         padding:0;
    }
    
    #center {
         width: 300px;
         height: 200px;
         position: absolute;
         top: 40%;
         left: 0px;
         width: 100%;
    }
    
    #loader {
         background-color: red;
         position: absolute;
         left: 0px;
         top: 0px;
         width:100%;
         height:100%;
         text-align:center;
         z-index: 1000;
         opacity: 0.5;
         filter: progid:DXImageTransform.Microsoft.Alpha(opacity=80);
    }
    ​
    

    Heres a jsbin, showing the result.

    http://jsbin.com/owaciy/2/

    ** UPDATE **

    By replacing position:absolute with position:fixed, you should be able to achieve the desired result:

    http://jsbin.com/owaciy/3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display some data which comes from my db using jQuery.ajax() (i.e.
I want to do the search using ajax jquery js, for that I have
I'm using jQuery Mobile and want to turn of Ajax handling because it does
I want to display a circular progress indicator using jquery in asp.net when textbox
I am using PHP. I want finish the jQuery AJAX process, (finish process and
I've data returned in json as {id:[update1,update2]} called using jQuery Ajax(). I want to
I am using jquery fancybox and I want to display a vertical scrollbar if
I am using JQuery ajax call for sending synchronized call to server and want
I am using JQUERY .ajax() to send serialized form data to MySQL using PHP.
I'm having trouble using jQuery.ajax() to post a gist to Github. The gist is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.