Pomster
Pomster

Reputation: 15197

Display loading gif on every site loading and posting?

I have added two functions to my site master to show and hide my loading gif. But don't want to call it from ever ajax call or before post method.

Is the no jQuery for me to check if the site is loading and then call the show method. I notice during a post the tab that my site is on has a loader, how do they check when to show it and can i call my loader on the same method?

The big problem is my asp.net submit buttons sometimes take very long with complex functions and need a loader to be show.

Upvotes: 0

Views: 57

Answers (1)

Nicholas Cloud
Nicholas Cloud

Reputation: 1574

You can tap into global AJAX events to show/hide your loading gif on every AJAX call:

$.ajax({
   beforeSend: function(){
     // show loading gif
   },
   complete: function(){
     // hide loading gif
   }
 });

see: https://api.jquery.com/Ajax_Events/

Upvotes: 1

Related Questions