Tag Archives: Grid++Report

Uncaught Error: Error calling method on NPObject.

1. Error description

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/.

Get the first value: undefined

Uncaught Error: Error calling method on NPObject.
Uncaught 
Error: Error calling method on NPObject.

2. Error reason

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);
		});
	});
}

When making Report by Grid++Report, whether to open the print window is controlled by a parameter isPrint; When isPrint=true, the print window is displayed, otherwise it is not displayed. However, if the query results do not have this parameter and are used directly in Print(isPrint), an Error Error will be reported calling method on NPObject

3. Solutions
Add the judgment before report.print (isPrint) USES this parameter

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);
		});
	});
}