[resolved] jQuery - animating AJAX for links.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Vael Victus
Forum Newbie
Posts: 24
Joined: Wed Jun 03, 2009 9:29 am

[resolved] jQuery - animating AJAX for links.

Post 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);
    });
   });
});
Last edited by Vael Victus on Wed Oct 21, 2009 6:27 pm, edited 1 time in total.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: jQuery - animating AJAX for links.

Post 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
        });
    });
});
Vael Victus
Forum Newbie
Posts: 24
Joined: Wed Jun 03, 2009 9:29 am

Re: jQuery - animating AJAX for links.

Post by Vael Victus »

Ahh yeah I knew of the fadein, but had no idea to form it like that. Excellent, thank you much.
Post Reply