Southeast Asian Bill Gates $_REQUEST, what a joke!
Aug 18

JqueryRecently, I’ve been using Jquery framework to do all my Javascript chores. Needless to say, I love it. Documentation rocks, easy to implement and lovely syntax. The reason I write this post is not to praise Jquery but to see whether anyone experience some kind of weirdness in their effect functions.

So weirdness came, when I fetch my information using AJAX and construct the information in HTML. Subsequently, I insert the HTML using append() and after that I slideDown() it. It works perfectly fine - no lagged.

However, when I shift the slideDown() outside of the AJAX, $.getJSON(), it gives some sort of lagged. Weird huh?

Snippet of the code below…

Lagged Version

$.getJSON("ajax/get_contact_person.php", { id : person_id }, function(json){

html += // All the HTML codes;

// Insert the retrieved information
$(”div#contact_” + person_id).append(html);
});

// Slide out the information
$(”div#contact_” + person_id).slideDown(”medium”);
Smooth Version

$.getJSON("ajax/get_contact_person.php", { id : person_id }, function(json){

html += // All the HTML codes;

// Insert the retrieved information
$(”div#contact_” + person_id).append(html);

// Slide out the information
$(”div#contact_” + person_id).slideDown(”medium”);
});
Any explanation will be grateful. :)

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Facebook
  • del.icio.us
  • Mixx
  • Google
  • Technorati
  • Live
  • NewsVine
  • YahooMyWeb
  • e-mail

written by mickeyckm

4 Responses to “Weird Jquery slideUp() and slideDown() Effects”

  1. 1
    University Update - AJAX - Weird Jquery slideUp() and slideDown() Effects Says:

    […] Link to Article ajax Weird Jquery slideUp() and slideDown() Effects » This excerpt is from an […]

  2. 2
    John Resig Says:

    That’s because, in the first one, you’re starting the animation before the Ajax request has finished - and before the new content has been loaded into the div. By waiting until the div actually has some contents in it, the slideDown will perform smoothly.

  3. 3
    mickeyckm Says:

    John Resig: Thanks for the reply. Now I get it.

  4. 4
    wmwebtr ödüllü seo yarışması Says:

    […] Link to Article ajax Weird Jquery slideUp() and slideDown() Effects » This excerpt is from an […]

Leave a Reply