jquery Plug-in Source:
/** * Encapsulates the $.ajax in jquery to add a lock screen function * IsAsync is an asynchronous request, the default is true * Islock whether to lock the screen, default is true * Iscache whether to load the information from the browser cache, the default is Fasle ***/; (function ($) {$.fn.dopost = function (settings) {settings = Jquery.extend ({isasync:true, type: "Post", Url:null, data
Type:null, Data:null, Success:null, Error:toerror, Islock:true, iscache:false}, settings); $ (this). each (function () {if (Settings.islock) {locksrc ();} $.ajax ({async:settings.isAsync, type:settings.type, url: Settings.url, DataType:settings.dataType, Data:settings.data, Cache:settings.isCache, Success:function (msg) {if (
Settings.islock) {unlocksrc ();} settings.success (msg);
}, Error:settings.error});
}); Lock Screen method function 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=" +
divwidth+ ", left=" +divleft+ ", top=" +divtop ";
$ (". Lockdivinfo"). css ({"position": "Absolute", "top":d ivtop, "left":d Ivleft}). fadeIn (' normal '); }//Jie Shi method function Unlocksrc () {$ (". Lockdivinfo"). Fadeout (' normal '); $ (". Lockdiv"). Fadeout (' normal ');} function
Toerror () {alert ("Operation failed!");}
}; }) (JQuery);
Lock screen Style:
/* Lock
screen
/* Lockdiv {
width:100%;
height:100%;
Display:none;
Z-index:10;
Background-color: #DFE8F6;
Position:absolute;
top:0px;
left:0px
}
. lockdivinfo {
width:50px;
height:2px;
Display:none;
Position:absolute;
left:0px;
top:0px;
Z-index:11
}
#CloseDiv {
float:right;
width:100px;
height:100px;
margin-top:10px;
margin-right:10px;
}
<div class= "Lockdiv" ></div>
<div class= "Lockdivinfo" >
</img>
</div>
How to use
Query
$ ("#queryBtn"). Click (function () {
seleccheckbyregionapp.query ();
});
var seleccheckbyregionapp={};
Seleccheckbyregionapp.query=function () {
var settion={
type: "Post",
URL: ' selfcheckstatisticaction! Findbyregion ',
dataType: "Text",
data:$ ("#searchForm"). Formserialize (),
success:function (msg) {
$ ("#contentDiv"). HTML (msg);
}
;
$ ("#queryBtn"). DoPost (settion);