function processJasperReport(filePath, fileName, fileType) {
CheckSecurityForJasperReport(filePath, fileName, fileType);
//call another funcation to run report }
function CheckSecurityForJasperReport(filePath, fileName, fileType) {
if(security == "true")
{
$.ajax({
type : "post",
dataType: "json",
url :"../CheckExecutePriviledge",
data: "reportpath="+filePath+"&reportname="+fileName,
success:function(content)
{ priviledge=content;
if( priviledge==false)
{
alert("You do not have permission to access this report");
return;
}
}
});
}
}
答案 0 :(得分:1)
我认为CheckSecurityForJasperReport
应该返回/定义进一步的操作,而不是直接从那里停止。我想到的快速解决方案是这样的 -
(可以优化: - ))
function CheckSecurityForJasperReport(filePath, fileName, fileType) {
var priviledge = false;
$.ajax({
type : "post",
dataType: "json",
url :"../CheckExecutePriviledge",
data: "reportpath="+filePath+"&reportname="+fileName,
success:function(content)
{
priviledge = content;
}
});
return priviledge;
}
function processJasperReport(filePath, fileName, fileType) {
// if security is enabled
var action_go_ahead = CheckSecurityForJasperReport(filePath, fileName, fileType);
if (action_go_ahead){
// proceed
}else{
// STOP, nothing to do here.!
}
}