Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a busy icon on my page which has a class of "hidden". When the user clicks a button to start processing input data, I want to show the busy icon. I am doing this with

$("#busy").removeClass("hidden");

Immediately after removing the hidden class, I use AJAX to get some data from the server, display it on the page and add the hidden class back to the busy image.

My problem is that the busy icon is never displayed. I'm not a javascript/jQuery expert but I think this is because the page isn't redrawn until after the script has finished executing?

How can I get the busy icon to display while the AJAX processing is in progress?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
143 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this

First u link ur image on a div

Then

Try this, it will work fine

$.ajax({
   url : "URL",
   data: { data },
   beforeSend: function(){
     $("#loading").show();
   },
   complete: function(){
     $("#loading").hide();
   },
   success:  function (response) {

   });
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...