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

  • SEARCH
  • Home
  • 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 6909791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:44:03+00:00 2026-05-27T08:44:03+00:00

I have some problems with displaying an AJAX loader inside a table cell. I

  • 0

I have some problems with displaying an AJAX loader inside a table cell.

I want it to be displayed over the cell to underline that there is data being loaded into it. However, I am experiencing problems with properly positioning it.

My base solution:

CSS:

.loader {
    z-index: 30;
    text-align: center;
    background-color: #f00; /* Red, so I could see it properly */
    opacity:0.5;
    filter:alpha(opacity=50); /* For IE8 and earlier */
    position: relative;
}

JS:

displayCellLoader: function (cell) {
  var loader = $("<div>").addClass("loader").css({
    width: cell.width(),
    height: cell.height(),
    left: 0,
    top: 0
  });
  cell.append(loader);
}

However, this design has some flaws:

  1. If the table cells have padding (and they have) the loader won’t cover it
  2. The loader will be displayed below any content the cell contains, not over it (as exppected)

A screenshot of the problem:
Loaders without padding

I thought the best way to eliminate these flaws would be to position the loader absolutely but it caused a different problem:

The loader’s left and right CSS properties are taken from the results of the offset() method, however for an unknown reason the loaders are displayed somewhat moved to the right (and a little to big).

Here is my modified JS:

displayCellLoader: function (cell) {
    var offset = cell.offset();
    var loader = $("<div>").addClass("loader").css({
        width: cell.innerWidth(),
        height: cell.innerHeight(),
        left: offset.left,
        top: offset.top
    });
    body.append(loader); /* body is $("body") */
}

And this is how it looks like now:
Loaders moved to the right

Does anyone know why does it happen?

And, more importantly, is there a better way to do it?

EDIT: There was a solution posted, about a way I didn’t mention here – appending absolutely positioned div into a td, which has position: relative. At first I thought “How on Earth could I forget about such obvious method?”, however after testing it, I noticed that it doesn’t work. The divs became positioned relatively to the table container, not to the cell itself.

I googled the issue and found this question. Quoting the best answer,

This is because according to CSS 2.1, the effect of position: relative
on table elements is undefined.

So this solution doesn’t apply to my case. The way to go would be to modify the template so all my table cells contain a div with position:relative which I could use to position the loaders. This solution is kind of painful for me, because it involves a lot of modifications in my code, so I’ll use it as a last resort.

I also don’t know why did the poster delete his answer – it could prove useful to others.

  • 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-05-27T08:44:03+00:00Added an answer on May 27, 2026 at 8:44 am

    Well, I ended up embedding cell contents into a div, like this:

    displayCellLoader: function (cell) {
        var paddingTop = parseInt(cell.css("padding-top"));
        var paddingLeft = parseInt(cell.css("padding-left"));
        var tempDiv = $("<div>").css({
            position: "relative",
            height: cell.height()
        }).html(cell.html());
        cell.empty().append(tempDiv);
        var loader = $("<div>").addClass("loader").css({
            width: cell.width(),
            height: cell.outerHeight(),
            top: -paddingTop,
            left: -paddingLeft
        }).append($("<img>").attr("src", "images/loader-cell.gif"));
        tempDiv.append(loader);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems displaying a ProgressDialog. I have a method that scrapes information
i want to use .animate function but i have some problems i want to
I have some problems displaying data in JTable. My app is using a JTable
I'm new in JSF and I have some strange problems in displaying conditional parts
I have some weird problems with jQuery ajax. I am calling jQuery ajax function
I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I
I have some problems on a site with the concurrent access to a list.
I have some problems sending mails through SMTP using Spring's MailSender interface and the
I have some problems with OpenCV s cvCanny(...) and the Image data types it
i have some problems with rowspan: var doc1 = new Document(); doc1.SetPageSize(PageSize.A4.Rotate()); string path

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.