开发者

Loading text while waiting for a Ajax call

I'm new to Javascript/Jquery/Ajax and don't know how to get some text to display 'Loading...' while waiting for an ajax call.

So fa开发者_StackOverflow社区r I have this code which works fin

$.get("sum.php", { userid: "<?php echo $userID; ?>"},
           function(data){


                eval(data);

});

I want 'Loading...' to appear in a div called Loading until the data is returned from the Ajax call.

Thanks in advance


If your loading div has ID "loading", you could do something like this...

<div id="loading"><img src="spinner.gif" /> Loading...</div>

JavaScript using jQuery ajaxStart and ajaxStop:

$("#loading").ajaxStart(function(){
   $(this).show();
})
.ajaxStop(function(){
   $(this).hide();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜