Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Thanked 0 Times in 0 Posts

    ummm, can someone explain this nonsensical "lag" with Ajax content loading?

    hey all, i'm having a weird problem, and my situation is a bit complex so i'll just break it down into a psuedo-example which experiences the very same problem. lets say i have a function which loads content into a DIV container called parentBox. the content that gets loaded into parentBox from "main.html" has a DIV inside of it with the ID of "redSquare".

    right after i load the main.html file into the parentBox, i'm trying to animate redSquare by sending it to another function. an example:

    function initializeMain() {
    loadpage('main.html', 'parentBox');
    however, beginAnimation fails, saying redSquare is not valid, or does not exist. BUT - if i make it wait for like 2 seconds by having it sit inside of a setTimeout, then it works! this doesn't make any sense to me - VISUALLY, the content loads instantaneously! everything is there! but for some reason, i can't access any of the elements inside it for like 1-2 seconds.. it's like everything loads visually, but the "id" information takes longer to kick in.

    now, i don't want to use this crude setTimeout function to wait 2 seconds, because that's extremely arbitrary ... what if, in real life on a server, it takes like 5 seconds for this weird problem to load? 2 seconds might not be enough time.

    so first.. why is this happening? secondly, how can i let beginAnimation know when it's ok to start accessing the DIV elements inside of parentBox?

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Toronto, ON, Canada
    Thanked 0 Times in 0 Posts
    Did you try to put beginAnimation in the callback method, using async mode.
    rm -f /


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts