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

The Archive Base Latest Questions

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

I have an issue I can’t get over. I made a simple jQuery album

  • 0

I have an issue I can’t get over. I made a simple jQuery album gallery and I have this function:

function loadAlbum (index) {
    for (var j=1; j < xmlData[index].length; j++) {

        var img = new Image();

        $(img).load(function() {
                    $(this).hide();
                    $('#album'+index+' .photoContainer').append(this);
                    $(this).fadeIn();
                })
                .error(function(){
                    //alert("Could not load one or more photo!");
                })
                .attr({
                    'src': xmlData[index][j],
                    'id': 'img'+index+j,
                    'class': 'photoFrame',
                    'width': newW,
                    'height': newH
                })
                .css({
                    'width': newW,
                    'height': newH
                });
    };
};

Now, as you can see all the images src’s are imported from an external XML file containing the data (images names are progressive ex.:photo001.jpg, photo002.jpg and so on).

They are created in the DOM trough a for loop and appended to a div.

What’s the issue you may say ? I need all images to be appended in a progressive way as specified on the XML data but this happens only on the local computer and not if uploaded on some server. I figure out that this is due to the different loading time of each image depending on size… but I still can’t figure out how to work this around. Does anyone have any idea?

  • 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-20T10:23:21+00:00Added an answer on May 20, 2026 at 10:23 am

    The following attempts to load one image at a time. Once an image is loaded, the next in the set is loaded afterward.

    function loadAlbum(index) {
        var i = 0;
        var j = xmlData[index].length;
        function loadImage() {
             if (i >= j) return;
    
             // do what you're doing in the loop except for ....
             $(img).load(function() {
                 $(this).hide();      
                 $('#album'+index+' .photoContainer').append(this);
                 $(this).fadeIn();
                 // increments i by 1 and calls loadImage for the next image.
                 i++;
                 loadImage();
             // etc.
        }
        loadImage();
    }
    

    I leave it as an exercise for you to determine how multiple images can be loaded at once and still maintain the ordering 🙂

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

Sidebar

Related Questions

I have this issue that I can't seem to get my head around... Basically
My issue can be seen here: http://jasonnarciso.com/dev/cmwd/concrete-solutions/ Basically I have a very simple jquery
Contributing to open source can have many forms: working with issue trackers, patches, further
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have an issue that I can't seem to solve. I am randomly generating
I'm sure this issue can be solved rapidly, but I don't find any answer
I'm sure this issue can be solved rapidly, but I don't find any answer
I have an odd issue that I can not for the life of me
I have a very strange issue, that I'm hoping someone here can help me
I have issue where i want to create Dynamic function which will do some

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.