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 921101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:49:13+00:00 2026-05-15T18:49:13+00:00

I have multiple divs in a page whose content gets loaded via ajax. I

  • 0

I have multiple divs in a page whose content gets loaded via ajax. I would like to show a loading gif that does the following, basically ajax_load_comments and pics are divs with animated gif backgrounds (in comments and pics container respectively), that show up on ajaxStart and hide on ajacstop.

Problem is they both show up regardless which container is being updated. How can I bind them to ajaxStart of a particular container? I like the one time binding in a main js file, rather than doing multiple bindings in different pages.

 $("#ajax_load_pics, #ajax_load_comments").bind("ajaxStart", function(){
        $(this).fadeIn('slow');
        $(this).parent().animate({
            opacity: 0.3
        }, 'slow', function() {
            // Animation complete.
            });

    }).bind("ajaxStop", function(){
        $(this).fadeOut('slow');
        $(this).parent().animate({
            opacity: 1
        }, 'slow', function() {
            // Animation complete.
            });
    });

Ok, well here is what I am doing now, but I don’t really see the loading div.

 $('.pagination a').live("click", function () {
        showLoad($(this).parent());
       /* $.get(this.href, null, function (data) {
            $('#com_prog_loading').fadeOut('slow');
            elem.remove($('#com_prog_loading'));
        }, 'script');*/
        $.get(this.href, null, null, 'script');
        return false;
    });

function showLoad(elem) {
    elem.parent().prepend("<div id='com_prog_loading'></div>");
    $('#com_prog_loading').fadeIn('slow');
}

function hideLoad() {


}
  • 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-15T18:49:14+00:00Added an answer on May 15, 2026 at 6:49 pm

    Sry for the confusion:

    $('.pagination a').live("click", function () {
            var $loadingDiv = $(this).closest('div.loading').fadeIn(); 
            $.get(this.href, function() {
                                $loadingDiv.fadeOut();
                             }, 'script');
            return false;
        });
    

    This uses closest to travel up the DOM and find your loading div and show it. The ajax callback hides it. If you’re looking to have independent status for different calls, you have to manage them manually.

    This assumes you put your loading divs into the markup and hide them via css, such as

    <style> div.loading { display: none; } </script>
    
    <div class="pagination">
       <div class="loading" >Loading message or animate gif or something</div>
       <div class="content">Maybe ajax content goes here? not sure about what you're doing exactly</div>
       <a href="url.html">Link</a>
    </div>
    

    If you really want to create the elements manually:

    $('.pagination a').live("click", function () {
                var $loadingDiv = $('<div>', {
                                         class: 'loading' // be sure to use class, id's are specific to ONE element only
                               }).appendTo( $(this).closet('.pagination') ) // or whatever closest class exists - again, not sure of your markup
                                 .html('Loading...'); // but i  think it's just an animated gif, ya?
                                 .fadeIn(); 
                $.get(this.href, function() {
                                    $loadingDiv.fadeOut('fast', function() {
                                                                   $(this).remove();    
                                                               });
                                 }, 'script');
                return false;
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple toggle divs on the same page, and the div I'm toggling
I would like to view/hide divs on a page, based on attribute filters. I've
I have a webpage that I use h1 tags multiple times within various DIVs
I have multiple projects in a couple of different workspaces. However, it seems like
I hope I can word this okay. I have multiple divs all called '.collapse-conten'
I want to have multiple video icons at the top my website's front page.
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
You have multiple network adapters. Bind a UDP socket to an local port, without
We have multiple MFC apps, which use CMutex( false, blah ), where blah allows
I have multiple classes that all derive from a base class, now some of

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.