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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:03:24+00:00 2026-06-01T22:03:24+00:00

Good Morning at all, I’ve a problem with asyncronus ajax loading…. I’ve Done a

  • 0

Good Morning at all,

I’ve a problem with asyncronus ajax loading….

I’ve Done a dinamic gallery and i want to load the images after that the page has been loaded.

But when i try to fade in the images and fade out the spinner the only one that seems to gone perfectly is the last element.. Why?

What i could do? Thanks!

js File

$('.Home-Image').each(function(index) {

MyHolder = $(this).children(".Home-Image-Holder");
MyLoader = $(this).children(".Home-Image-Loader");

IDIMG = $(MyHolder).attr("AjaxRel");


$(MyHolder).load('<?PHP echo($ABS); ?>/inl/components/AjaxImageHome.php?ABS=<?PHP echo $ABS; ?>&IDIMG='+IDIMG, function()
{
    MyLoader.fadeOut(250,0,function(){MyHolder.fadeIn();}); 
});

});

Html File

<div class="Home-Image">    
   <div class="Home-Image-Loader"></div>
   <div class="Home-Image-Holder" AjaxRel="1"></div>
</div>

<div class="Home-Image">    
   <div class="Home-Image-Loader"></div>
   <div class="Home-Image-Holder" AjaxRel="2"></div>
</div>

<div class="Home-Image">    
   <div class="Home-Image-Loader"></div>
   <div class="Home-Image-Holder" AjaxRel="3"></div>
</div>


<div class="Home-Image">    
   <div class="Home-Image-Loader"></div>
   <div class="Home-Image-Holder" AjaxRel="4"></div>
</div>
  • 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-01T22:03:25+00:00Added an answer on June 1, 2026 at 10:03 pm

    My guess is that your .each() function finishes the loop faster than the .load()‘s callback functions run.

    because of this, by the time the .load() function runs, the loop is finished and MyHolder and MyLoader equal to the last time you defined them (in the last .each() run).

    SOLUTION:

    $('.Home-Image').each(function(index) {
    
    MyHolder = $(this).children(".Home-Image-Holder");
    MyLoader = $(this).children(".Home-Image-Loader");
    load_img(MyHolder,MyLoader);
    
    
    function load_img(MyHolder,MyLoader){
       IDIMG = $(MyHolder).attr("AjaxRel");
       $(MyHolder).load('<?PHP echo($ABS); ?>/inl/components/AjaxImageHome.php?ABS=<?PHP echo    $ABS; ?>&IDIMG='+IDIMG, function()
       {
           MyLoader.fadeOut(250,0,function(){MyHolder.fadeIn();}); 
       });
    }
    

    This way, once you run load_img, your two variables are saved in a different scope, and will not overwrite themselves on your next .each() iteration.

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

Sidebar

Related Questions

Good morning to all, What is the preferred way to embed images (and other
Good morning all. I have an issue with a query. I want to select
Good morning all, i want to create an event in MySQL that will UPDATE
Good Morning All, I have created a different background and a few other images
Good morning all, I'm having a few problems with a method in my C#
Good morning all. Is there any jsf control that escapes the html tags? Imagine
Good morning all! Myself and a co-worker are tasked with a system-wide scripting solution
Good morning all, I'm sure this is a gimme, but I have no idea
Good morning all, After a day of googling, I’m at a loss. I decided
Good-morning one and all! This is going to end up being one of those

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.