1、错误描述
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
For more help, check http://xhr.spec.whatwg.org/.
获取到第一个值:undefined
Uncaught Error: Error calling method on NPObject.
Uncaught
Error: Error calling method on NPObject.
2、错误原因
function windowOnload() {
Report.LoadFromURL("student.grf?date="+(new Date().getTime()));
$.ajax({
url:"param/isPrint",
type:"get",
dataType:"json",
async:false,
}).done(function(resp){
if(dt.success==false){
return;
}
var isPrint=resp.isPrint;
$.ajax({
url:"student/stu/findStu",
type:"get",
dataType:"json",
data:{},
async:false
}).done(function(data){
if(!data){
return;
}
var report = JSON.stringify(data);
Report.LoadDataFromAjaxRequest(report,"application/json;charset=UTF-8");
Report.Print(isPrint);
});
});
}
利用Grid++Report制作报表时,是否打开打印窗口,利用一个参数isPrint来控制;当isPrint=true,显示打印窗口,否则不显示。但是,如果查询出来的结果没有这个参数,并且直接在Print(isPrint)使用,这时会报错Error calling method on NPObject3、解决办法
在Report.Print(isPrint)使用这个参数前,添加判断
function windowOnload() {
Report.LoadFromURL("student.grf?date="+(new Date().getTime()));
$.ajax({
url:"param/isPrint",
type:"get",
dataType:"json",
async:false,
}).done(function(resp){
if(dt.success==false){
return;
}
var isPrint=resp.isPrint;
$.ajax({
url:"student/stu/findStu",
type:"get",
dataType:"json",
data:{},
async:false
}).done(function(data){
if(!data){
return;
}
var report = JSON.stringify(data);
Report.LoadDataFromAjaxRequest(report,"application/json;charset=UTF-8");
Report.Print(isPrint?true:false);
});
});
}