Andreea Barbu
Andreea Barbu

Reputation: 1

Load Image With AJAX (jQuery)

i have this script:

$.ajax({
    type: "GET",
    url: '/get.php?id=' + c + '&type=1',
    dataType: "html"
}).done(function (a) {
    $(".playerr:eq(" + b + ")").html(a).show()
});

how can i add an loading image ?

Upvotes: 0

Views: 1478

Answers (1)

Adil
Adil

Reputation: 148110

You can use beforeSend and success or done to show and hide the loading image

$.ajax({
    type: "GET",
    url: '/get.php?id=' + c + '&type=1',
    dataType: "html"
}).done(function (a) {
    $(".playerr:eq(" + b + ")").html(a).show();
    $("#img1").hide();
}).beforeSend(function(){
      $("#img1").show();
});

Upvotes: 1

Related Questions