zoukankan      html  css  js  c++  java
  • Uncaught Error: Error calling method on NPObject.

    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 NPObject


    3、解决办法

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


  • 相关阅读:
    zookeeper笔记整理(二)
    zookeeper笔记整理(一)
    SpringBoot源码分析(三)整合MyBatis
    四、MyBatis终结篇(补充中...)
    三、SpringMVC终结篇(补充中...)
    二、SpringAOP终结篇(补充中...)
    一、SpringIOC终结篇(补充中...)
    跳出初学MySQL知识的原理整理(一)
    SpringBoot源码分析(二)启动原理
    一文带你学会基于SpringAop实现操作日志的记录
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313821.html
Copyright © 2011-2022 走看看