SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Posts rarely lloydi's Avatar
    Join Date
    Jan 2002
    Location
    Swindon UK
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having a jQuery timing problem .. any help?

    I'm building something that is very jQuery intensive. Have had no problems at all until *literally* the last phase.

    Basically I have three panels which are hidden or shown depending on what stage you are in. In panel 3 there's a bit of AJAX that loads in some content based on choices made in panels 1 and 2.

    here's a summary of the code:

    //much earlier:
    $("#step3").hide();

    //later:
    $("#step2").slideUp('medium');
    $("#step3").slideDown('medium');
    $("#step3 #genCSS").load("select-style-css.php?id="+ chosenStyle);

    ** The problem **
    The AJAX part always fails to work ... unless I comment out the initial hide() function. Basically, the AJAX load event appears to be firing too early.

    Somehow I need to wait until #step3 has been made visible and is ready for having content put into the #genCSS div.

    I've tried timeouts, I've tried placing the AJAX load thing as a callback function inside the slideDown ... but none of it seems to work.

    I'm sure that I'm missing something simple and it's driving me crackers, so any help will be appreciated!
    Build Your Own Web Site the Right Way!
    A beginners' HTML/CSS book with web standards at its heart
    The Ultimate HTML Reference
    A complete reference, in glorious hardback

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Placing the Ajax call as a callback function of the slideDown should work... In fact you shouldn't need to do this at all - it should work regardless of whether the element is hidden or not.

    What is in "select-style-css.php" and what is 'chosenStyle'?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where did you get "medium" from? The "speed" parameter for the effects (slideUp,slideDown etc.) has to be defined either in milliseconds of "slow","normal" or "fast"... - http://docs.jquery.com/Effects/slideDown#speedcallback
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)


Bookmarks

Posting Permissions

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