Uncaught Error: Error calling method on NPObject.

快来打我* 2022-06-07 03:44 321阅读 0赞

1、错误描述

  1. Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
  2. For more help, check http://xhr.spec.whatwg.org/.
  3. 获取到第一个值:undefined
  4. Uncaught Error: Error calling method on NPObject.
  5. Uncaught
  6. Error: Error calling method on NPObject.

2、错误原因

  1. function windowOnload() {
  2. Report.LoadFromURL("student.grf?date="+(new Date().getTime()));
  3. $.ajax({
  4. url:"param/isPrint",
  5. type:"get",
  6. dataType:"json",
  7. async:false,
  8. }).done(function(resp){
  9. if(dt.success==false){
  10. return;
  11. }
  12. var isPrint=resp.isPrint;
  13. $.ajax({
  14. url:"student/stu/findStu",
  15. type:"get",
  16. dataType:"json",
  17. data:{},
  18. async:false
  19. }).done(function(data){
  20. if(!data){
  21. return;
  22. }
  23. var report = JSON.stringify(data);
  24. Report.LoadDataFromAjaxRequest(report,"application/json;charset=UTF-8");
  25. Report.Print(isPrint);
  26. });
  27. });
  28. }
  29. 利用Grid++Report制作报表时,是否打开打印窗口,利用一个参数isPrint来控制;当isPrint=true,显示打印窗口,否则不显示。但是,如果查询出来的结果没有这个参数,并且直接在Print(isPrint)使用,这时会报错Error calling method on NPObject

3、解决办法

  1. Report.Print(isPrint)使用这个参数前,添加判断
  2. function windowOnload() {
  3. Report.LoadFromURL("student.grf?date="+(new Date().getTime()));
  4. $.ajax({
  5. url:"param/isPrint",
  6. type:"get",
  7. dataType:"json",
  8. async:false,
  9. }).done(function(resp){
  10. if(dt.success==false){
  11. return;
  12. }
  13. var isPrint=resp.isPrint;
  14. $.ajax({
  15. url:"student/stu/findStu",
  16. type:"get",
  17. dataType:"json",
  18. data:{},
  19. async:false
  20. }).done(function(data){
  21. if(!data){
  22. return;
  23. }
  24. var report = JSON.stringify(data);
  25. Report.LoadDataFromAjaxRequest(report,"application/json;charset=UTF-8");
  26. Report.Print(isPrint?true:false);
  27. });
  28. });
  29. }

发表评论

表情:
评论列表 (有 0 条评论,321人围观)

还没有评论,来说两句吧...

相关阅读