开发者

How to make jQuery show Loading picture while doing a function?

开发者 https://www.devze.com 2023-02-16 04:27 出处:网络
How to make jQuery show Loading picture while doing开发者_如何学JAVA a function?I guess you are performing some asynchronous operation. Perhaps $.ajax? Here is a code snippet:

How to make jQuery show Loading picture while doing开发者_如何学JAVA a function?


I guess you are performing some asynchronous operation. Perhaps $.ajax? Here is a code snippet:

$('<div class="loading">loading ... </div>').appendTo(document.body);
$.ajax({ 
 url: "...",
 complete: function () {
    $("div.loading").remove();
 },
 success: function() {
   //....
 }
}


If you are trying to block the UI while ajax calls are running. You should take a look at jQuery BlockUI. I have used it in a mobile app and it works well. You can add text and gif images to customize the blocking screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号