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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:20:21+00:00 2026-05-24T06:20:21+00:00

Problem: Multiple asynchronously invoked Effect.Appear() calls do not all resolve properly. Background: I have

  • 0

Problem:
Multiple asynchronously invoked Effect.Appear() calls do not all resolve properly.

Background:
I have a page that lazy loads 10-20 items from a different server. Because of current architecture, each item must be loaded with its own http request (as opposed to a batch request), so I can’t wait for all those http requests to come back before the page finishes loading–I really have to lazy load them to get a decent experience.

This was working fine until I wanted to put a little bit of polish on it by having the items fade in instead of brusquely appearing on the page. When I try to use Effect.Appear(), not all of the items appear every time. Inspecting the elements shows that the requests did come back, and that the dom elements did get attached, and the placeholder even got removed. But the element still shows a style=”display:none”.

It’s not the same element every time, and an element that was loaded fine before may not load properly on a soft refresh, so even caching doesn’t seem to help the problem.

Code:
Here’s the main code that controls the loading.

Javascript:

    /** create the html and attach it */
    createItem = function(photoDOM, json){
        //(creates this html)
        // <a href="<?=$itemPage?>" target="_blank">
        //      <img src="<?=$itemImage?>" 
        //        id="suggestedItemIMG_<?=$itemID?>" 
        //        class="suggestedItemIMG <?=$itemClass?>" 
        //        title="<?=$itemTitle?>"/>
        //      
        // </a>
        if(json.error == "removed"){
            photoDOM.remove();
            return false;
        }
        anchor = new Element('a', {
            href: json.a.href,
            target: '_blank'
        })
        img = new Element('img', {
            'class': "suggestedItemIMG " + json.img.itemClass,
            id: 'suggestedItemIMG_'+json.img.itemID,
            'title': json.img.imgTitle
        });
        anchor.appendChild(img);
        anchor.style.display = 'none';
        photoDOM.appendChild(anchor);

        img.observe('load', function(e){ //have it append to the doc after it loads and remove the placeholder
            photoDOM.down('.indicator').remove();
            anchor.appear({
                from: 0,
                to: 1
            });
        });

        img.src = json.img.src; //start loading
    }

    /** make the ajax request */
    loadItem = function(photoDOM){
        new Ajax.Request('/ajax/get_item.php', {
            parameters: { photoitem_id: photoDOM.select('.photoitem_id')[0].value },
            onSuccess: function(transport){
                var json = transport.responseText.evalJSON();
                createItem(photoDOM, json);
            }
        });
    }

PHP ajax handler:

    if($itemStatus > 99) {
        echo json_encode(array("error"=>"removed"));
        exit;
    }

    $json = array(
        "a" => array("href" => $itemPage),
        "img" => array(
            "src" => $itemImage,
            "itemID" => $itemID,
            "itemClass" => $itemClass,
            "imgTitle" => $itemTitle,
        ),
        "item" => array(
            "status" => $itemStatus
        )
    );
    echo json_encode($json);

Thanks for any help.
-K

  • 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-24T06:20:21+00:00Added an answer on May 24, 2026 at 6:20 am

    Try add a var anchor, img; somewhere in the function so they are scoped into the createItem function. Without it when img.observe is called the anchor points to the least set and not the proper one.

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

Sidebar

Related Questions

i have a problem calling multiple instance of a class that i have coded
The problem is this: I have multiple competing threads (100+) that need to access
Hi The problem am having is that I have multiple TreeView control and each
I have multiple user controls loading asynchronously on my page, using pagemethods. Some dropdownlists
i have been reading about multiple inheritance What is the exact problem with multiple
The problem. I have multiple tab, their content is loaded via ajax, so the
I have run into this problem across multiple programming languages and I was just
I have a method that queues some work to be executed asynchronously. I'd like
First the problem: I'm working on the application that uses multiple FragmentLists within a
I have a problem when multiple threads try to increase int. Here's my code:

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.