ajax 未加載出數據時,顯示loding,數據顯示后,隱藏loading


$("#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');
}
})
}

})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM