tags:

views:

16

answers:

1

Is there a way I can display the result and then have it fade away after about 10 seconds or something using JQuery?

Here is the code.

function stop(){
    $.ajax({
        type: "GET",
        url: "http://update.php",
        data: "do=getSTOP",
        cache: false,
        async: false,
        success: function(result) {
            $("#rate").html(result);
        },
        error: function(result) {
            alert("some error occured, please try again later");
        }
    });

    return false;
}

$(document).ready(function() {

    $('.rating li a, .srating li a').click(stop);

});
+4  A: 

You can use .delay() for this, like this:

$("#rate").html(result).delay(10000).fadeOut();

This does a .delay() for 10 seconds then performs a .fadeOut() animation, no reason to make it any more complicated I think :)

Nick Craver