Page 1 of 1

[resolved] jQuery - animating AJAX for links.

Posted: Wed Oct 21, 2009 3:12 pm
by Vael Victus
I'm pretty sure I'm being a huge noob, but I can't seem to figure it out.

http://murcity.com/layout.php

Right after the "hey" you see "I love ajax" blah blah. If you click that link it adds to the "hey" div, the contents of a file on my server. Perfect. What I want it to do is just now -fade in- and it's taken me nearly two hours of research and I simply can't seem to figure out how to do this.

The code in question is

Code: Select all

$(document).ready(function(){
   $("a#toggle2").click(function(){
     $.get("testyplox.php?omg=5", function(data){
     $("div#rofl").append(data);
    });
   });
});

Re: jQuery - animating AJAX for links.

Posted: Wed Oct 21, 2009 3:25 pm
by kaszu
jQuery has a fadeIn function

Code: Select all

$(document).ready(function(){
    $("a#toggle2").click(function(){
        $.get("testyplox.php?omg=5", function(data){
            var content = $('<span>' + data + '</span>'); //Create nodes, using span because we need element to fade in
            $("div#rofl").append(content); //Insert into DOM
            content.hide().fadeIn(); //fadeIn; using .hide() because on visible elements fadeIn will do nothing
        });
    });
});

Re: jQuery - animating AJAX for links.

Posted: Wed Oct 21, 2009 6:27 pm
by Vael Victus
Ahh yeah I knew of the fadein, but had no idea to form it like that. Excellent, thank you much.