Aug 18

Recently, I’ve been using Jquery framework to do all my Javascript chores. Needless to say, I love it.jquery_avatar_400x400[1] 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. 🙂

written by mangoorange


Best Wordpress Hosting Providers - 2014

All three hosts offer FREE 1-click Wordpress installs making them the best Wordpress hosting providers. For more web hosting reviews be sure to check out AlreadyHosting.com.

 #1
#2 
 #3
#1 - Bluehost 
Bluehost Review
#2 - iPage 
iPage Review
#3 - HostMetro 
HostMetro Review


One Response to “Weird Jquery slideUp() and slideDown() Effects”

  1. 1. mickeyckm Says:

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

Leave a Reply

You must be logged in to post a comment.