/**
* 处理等待效果
*/
function loading() {
$("<div id=\"loading\" class=\"datagrid-mask\"></div>").css({
display : "block",
width : "100%",
height : $(window).height()
}).appendTo("body");
$("<div class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候。。。").appendTo(
"body").css({
display : "block",
left : ($(document.body).outerWidth(true) - 190) / 2,
top : ($(window).height() - 45) / 2
});
}
function loadingHide(){
var _mask = jQuery("[class='datagrid-mask-msg']");
_mask.hide();
jQuery('#loading').hide();
}
document.ready时 执行loading
ajax 获取完数据,执行完dataFill()时,执行loadingHide()即可
附上较为完整jQuery代码:
var year=${year};
function dataFill(data){
var month = 1;
$("table tr").each(function(){
var fid ="" ;
if($(this).children("td:nth-child(2)").attr("id")!=undefined){
fid= $(this).children("td:nth-child(2)").attr("id")+"Qms";
var res = 0.0;//数据库中某字段的结果
var col = 3;//期初余额
if(data[month]==null){
}else{
month = 1;
fid = $(this).children("td:nth-child(2)").attr("id")+"Qcs";
res = data[month][fid];
var result = "";
if(res==null){result="";}
else {
result = res+"";
}
$(this).children("td:nth-child("+col+")").text(result);
}
for(month=1;month<=12;month++ ){//读取1到12月的数据 (一行)
var col = month+3;
if(data[month]==null){
}else{
res = data[month][fid];
var result = "";
if(res==null){result="";}
else {
result = res+"";
}
$(this).children("td:nth-child("+col+")").text(result);
}
}
}
});
}
function show(){
jsTool.ajax({
url:'${contextPath}/show/showZcfzb2.do',
data:{'year':year},
success:function(data){
if(data!=null){
dataFill(data);
loadingHide();
}
}
});
}
jQuery(document).ready(
function() {
loading();
show();
}
);
版权声明:本文为博主原创文章,未经博主允许不得转载。