Reputation: 29064
Suppose, you're working on a project that does a lot of jQuery.ajax
requests. Now you want to display a kind of "loading..."
message while a request is running.
How could you do that? You can't change all the $.ajax
calls (e.g. there are too many or it's important to have consistent behavior)
Need some guidance on this... Thanks...
Upvotes: 0
Views: 44
Reputation: 717
You can listening all ajax events like this :
$("#loading").bind("ajaxSend", function() {
$(this).show();
}).bind("ajaxComplete", function(){
$(this).hide();
});
more info in this page : http://docs.jquery.com/Ajax_Events
Upvotes: 0
Reputation: 66663
Check this: http://api.jquery.com/ajaxStart/
In that page, you'll see:
For show a loading message whenever an Ajax request starts (and none is already active).
$("#loading").ajaxStart(function(){
$(this).show();
});
Upvotes: 0
Reputation: 3185
Check this page: http://api.jquery.com/category/ajax/
You will see .ajaxStart()
. Check that page and I'm sure you will figure it out. Since your profile says: 'very keen in learning new things', I'm not going to give it all :-)
Upvotes: 1