Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Partial Overlay to cover ajax request

Partial Overlay to cover ajax request

Scheduled Pinned Locked Moved JavaScript
csharpdatabasesysadmindocker
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sentenryu
    wrote on last edited by
    #1

    Hello everyone, I'm searching for a way to do a overlay with a loading indicator cover only 1 div on the page. the reason i want to do this is that i'll have multiple sections in my pages that will do ajax calls to the server to get data and display in fields, most will be calculation results, so i don't want to replace the div's content, just the field value. in my searchs, i only found solutions for overlays that cover the entire screen, that's good, but i want the rest of the page to be accessible while the ajax request goes on the background. right now, i've the following code to create a overlay:

    var lockOverlayHtml = '

    ';

    var lockElement = (function (container) {
    var element = $(container);
    var overlay = $(lockOverlayHtml);

                      overlay.offset(element.offset());
                      overlay.height(element.outerHeight(false));
                      overlay.width(element.outerWidth(false));
                      overlay.appendTo(document.body);
                   });
    

    problem is, i can't think in a way to remove only this overlay when the ajax request ends, as it can be used to cover any element on the screen and i can have multiple ones at a time. what can i use to identify this overlay and remove it? i thought in something like generating a id using the coordinates, is it a good idea? also, don't know if i can ask this here, but the overlayDiv class looks like this:

    .overlayDiv
    {
    position: absolute;
    opacity: 0.5;
    z-index: 1000;
    background-color: #606060;
    }

    this will work even when the browser scrolls? or i need to do something else in that case?

    I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups