Can jQuery display the result if it disappears?

Is there a way to show the result and then it will disappear 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);

});
+5
source share
1 answer

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

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

It does .delay()for 10 seconds, then performs .fadeOut(), there is no reason to make it more complicated, I think :)

+19
source

All Articles