使用AJAX加载图像(jQuery)

时间:2013-08-19 11:39:06

标签: jquery ajax image loading

我有这个脚本:

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

如何添加加载图片?

1 个答案:

答案 0 :(得分:1)

您可以使用beforeSendsuccess或完成来显示和隐藏加载图片

$.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();
});