Code source du plugin jQuery:
/ *** encapsule $ .ajax en jQuery pour ajouter la fonction de l'écran de verrouillage * Isasync isasync est une demande asynchrone, la défaut est vrai * est-ce que l'écran est verrouillé, la valeur par défaut est vraie * isCache est de savoir si les informations sont chargées à partir du cache de navigateur, par défaut est fasle *** /; (fonctions = jQuery.Extend ({isasync: true, type: "Post", URL: null, dataType: Null, data: null, succès: null, error: toerror, islock: true, iscache: false}, Paramètres); $ (this) .each (function () {if (settings.islock) {locksrc ();} $. atype, data: settings.data, cache: settings.iscache, succès: fonction (msg) {if (settings.islock) {unlocksrc ();} settings.success (msg);}, error: sefitS.Error});}); // Fonction de la méthode de l'écran LOCK LOCKSRC () {$ (". LockDiv"). CSS ({"Opacity": "0,5"}). Fadein ('Normal'); var scrollWidth = document.DocumentElement.ClientWidth; // Document.Body.ClientWidth; var ScrollHeight = Document.DocumentElement.ClientHeight; // document.body.clientHeight; var divWidth = $ (". LockDivInfo"). width (); var divHeight = $ (". LockDivInfo"). Height (); var divleft = scrollwidth / 2-divwidth / 2; var divtop = scrollHeight / 2-divheight / 2; // console.log ("bodywidth =" + scrollwidth + ", bodyheight =" + scrollHeight + ", divheight =" + divheight + ", divWidth =" + divwidt H + ", Left =" + divleft + ", top =" + divtop); $ (". LockDivInfo"). CSS ({"position": "Absolu", "Top": divtop, "Lefre": divleft}). La fonction de méthode d'écran unlocksrc () {$ (". LockDivInfo"). Fadeout ('Normal'); $ (". LockDiv"). Fadeout ('Normal');} fonction toERROR () {alert ("Operation a échoué!");}};}) (jQuery);Style d'écran de verrouillage:
/ * Écran de verrouillage * /. LockDiv {largeur: 100%; hauteur: 100%; affichage: aucun; z-index: 10; fond-couleur: # dfe8f6; position: absolu; top: 0px; gauche: 0px;}. LockDivinfo {width: 50px; hauteur: 2px; affichage: non; position: absolue; gauche: 0px; top: 0px; 11} #closediv {float: à droite; largeur: 100px; hauteur: 100px; marge: 10px; marge-droite: 10px;}<div> </div> <div> <img id = "closev" src = "/ hnhd / images / cercle_animation.gif"> </img> </div>
Comment utiliser
// requête $ ("# queryBtn"). Cliquez sur (function () {seleccheckByRegionApp.Query ();}); var seleccheckByRegionApp = {}; seleccheckByRegionApp.Query = fonction () {var Settion = {type: "post", url: 'selbcheckstatisticAction! FindByregion' , dataType: "text", data: $ ("# searchform"). FormSerialize (), Success: function (msg) {$ ("# contentDiv"). html (msg);}}; $ ("# queryBtn"). dopost (settion);};