开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜