Processing displays a wait bar for Ajax requests until all AJAX requests are completed before closing the wait bar. Relatively simple, the source code is as follows (based on jquery)
Based on jquery//starting from the first Ajax request to show the wait bar? The wait bar is closed until a series of Ajax requests are complete. Any Ajax triggered by the Ajaxsend event will show the Wait box, all Ajax execution completed (Ajaxcomplete event) will not close the Wait box $ (function () {///need to listen for Ajax URL var listenurls = [ ],///wait bar selector loadingselector = '. Loading-container ',//wait bar to display the class Loadingclass to add = ' loading-ajax-active ' ; $ (document). On (' Ajaxsend ', function () {//Show wait Bar if (listenurls.length <= 0) {$ (Loadingselector) . addclass (Loadingclass); }//Add Listener URL Listenurls.push (arguments[2].url); }). On (' Ajaxcomplete ', function () {var ajaxurl = Arguments[2].url; for (var i = 0; i < listenurls.length; i++) {//delete completed AJAX request listener if (listenurls[i] = = Ajaxurl) { Listenurls.splice (i,1); }}//There is no need to listen for Ajax to close the wait bar if (listenurls.length <= 0) {$ (loadingselector). Removeclass (l Oadingclass); } }) });
Simple processing of waiting bars to be displayed and hidden under multiple Ajax requests