1. 程式人生 > >ajax 未加載出數據時,顯示oding,數據顯示後,隱藏loading

ajax 未加載出數據時,顯示oding,數據顯示後,隱藏loading

pos value 隱藏 current 模版 row res document window

$("#CreateReport").click(function () {
// RptID,Template,TemplateType,FileName
var RptID = $("#gridList").jqGridRowValue().RptID;
var Template = $(‘#‘ + RptID + "_Template").val();
var TemplateType = $(‘#‘ + RptID + "_TemplateType").val();
var FileName = $("#gridList").jqGridRowValue().FileName;

if (Template == "" || Template == undefined) {
$.modalAlert("報告模版還未選擇,請點擊報告模版選擇", ‘error‘);
return false;
} else if (Template == "請選擇報告模版") {
$.modalAlert("請選擇正確的報告模版", ‘error‘);
return false;
} else {
$.ajax({
url: "#",
data: {
RptID: RptID,
Template: Template,
TemplateType: TemplateType,
FileName: FileName
},
async: true,//必須是異步加載的


method: "POST",
beforeSend: function () {
$(‘#loadingPage‘, parent.document).css("display", "block");
},
success: function (result) {
var result = JSON.parse(result);
if (result["state"] == "success") {
$.modalAlert("成功生成報告,請在已出報告查看", ‘success‘);
$.currentWindow().$("#gridList").trigger("reloadGrid");
} else {
$.modalAlert(result.message, ‘error‘);
}
},
complete: function () {

$(‘#loadingPage‘, parent.document).css("display", "none");
},
error: function () {
$.modalAlert("出錯了", ‘error‘);
}
})
}

})

ajax 未加載出數據時,顯示oding,數據顯示後,隱藏loading