0

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 ?

1
  • my entire function is this : var pml = -1; function showpl(b, c, d) { if (pml != -1) $(".playerr:eq(" + pml + ")").html('').hide(); var b = $("." + d).index(b); $.ajax({ type: "GET", url: '/get.php?id=' + c + '&type=1', dataType: "html" }).done(function (a) { $(".playerr:eq(" + b + ")").html(a).show() }); pml = b; return false } Commented Aug 19, 2013 at 11:48

1 Answer 1

1

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();
});
Sign up to request clarification or add additional context in comments.

3 Comments

You can hide the image on .done() so even in case of error the image will be hidden, else it will keep on showing.
Not working is not clear statement, do you get beforeSend and done event?
image is not appear and all requests appear in first div

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.