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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:50:11+00:00 2026-05-12T19:50:11+00:00

I have what I thought was a relatively easy Ajax/animation that I’m adding to

  • 0

I have what I thought was a relatively easy Ajax/animation that I’m adding to a client site to select between projects for display as images. The flow goes something like this:

  1. User clicks on a thumbnail in a project overview (pHome).
  2. Using jQuery, ajax load in an XML file with the image, caption and project description data (project1).
  3. Construct the HTML from the XML file and inject it into the DOM (div id=”project1″).
  4. Animate and (4.5) fade out pHome.
  5. Fade in project1.
  6. Add a ‘puff’ effect to the thumbnail that brought the user to the project.

All of these things need to happen synchronously, but I can’t find the right flow for the functions. Attaching all of these steps to the user click fades out pHome before the animation completes, and the ‘puff’ effect fires before the project1 div is even visible.

As it is, I have functions for all of these steps, and it seems like a real mess. What I’m asking for is some best-practice way of structuring these functions so they all happen synchronously (with the possible exception of 2 & 3). Just as an aid, here’s the pseudocode for my problem:

$('#thumbnail').live('click', function(){
    loadXML(thumbnail_id);
    makeHMTL(data);
    $('pHome').animate({blah}).fadeOut();
    $('project1').fadeIn();
    $('thumbnail_id').puff();
});

I know this is obviously a bad way to do it – but I can’t figure out how to nest/structure the functions to make them all synchronous. And really I’d like an answer that gives me some way to structure my functions in the future to avoid rat-nests. Educate me! 🙂

  • 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-12T19:50:11+00:00Added an answer on May 12, 2026 at 7:50 pm

    Nesting animation functions is one way to do but can be nasty when you do a lot of them and you’ll easily lose overview.

    An option is to pack them all into an object and pass reference to the callback as such:

    $('#thumbnail').live('click', animation.step1);
    
    var animation = {
        step1: function() {
             $("#Element").show("puff", {}, "slow", animation.step2);
        },
        step2: function() {
             $("#Element").hide("linear", {}, "fast", animation.step3);
        },
        step3: function() {
             $("#Element").show("bounce", {}, 500);
        }
    }
    

    Or as an alternative you can use the built in animation queues like this:

    $("#go1").click(function(){
       $("#block1").animate( { width:"90%" }, { queue:true, duration:100 } )
                   .animate( { fontSize:"24px" }, 1500 )
                   .animate( { borderRightWidth:"15px" }, 1500);
    })
    

    Also check the documentation: link

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

Sidebar

Related Questions

I have a project that I thought was going to be relatively easy, but
I would have thought that this would be an easy thing to do, but
I have recently installed a website project on Azure and that was relatively easy
I would have thought this would be an easy one to Google, but I've
For a long time ago, I have thought that, in java, reversing the domain
I have an ASP.NET web site technology that I use for scores of clients.
I have a relatively simple question that I cant figure out and I cant
I have some Code that I'd like to share between an iOS and an
I'm trying to do what I thought was a relatively simple calculation between 2
I have a Moose object module that should accept a relatively large data structure

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.