如何在代码中找到"operation's"位置?"回调函数不支持此操作。"



我正在为文档创建一个Google插件。所以我使用html、scriptlet和java。一切都运行得很好,但突然间,我遇到了这个错误,我不知道如何解决它

当我运行html时,会出现错误,如表所示。在开发人员工具中,会显示以下错误:1.谷歌应用程序脚本:回调函数不支持此操作。2.给定的范围不属于当前选择的文档。3.G.Y0

如何获取这些信息来查找错误的位置?

每个请求的附加信息。。。。。。。。

对不起,我正在使用javascript。

我的html文件只有两个服务器端函数调用。第一种是通过scriptlet,它在加载html之前进行加载。此调用函数返回一个数组,该数组用于为表创建带有动态html的侧边栏。

<? var rubric = getRubric(); ?>

第二个按钮在侧边栏中。该按钮存储位于侧边栏中的单选按钮id,然后将它们发送到服务器端函数。我在上面放了一个withFailureHandler。

<td class="tableCalcButton"><input type="button"  class="button" value="Fill Rubric" onclick= "fillRubricA()"  /></td>
<script>
  function fillRubricA(){                              
            var selection = [];
            var matrix = document.getElementsByName('rbRubric').length;  // this = 20  a 4x5 matrix.
            selection[0] = [  [document.getElementById('rbRubric11').value], [ matrix / (document.getElementById('rbRubric11').value - 1) + 1 ] ];
            for ( var r = 1; r < selection[0][0]; r++) {
                   for ( var c = 1; c < selection[0][1]  ; c++) {
                          if (document.getElementById( 'rbRubric' + r + c).checked == true) { selection[r] = [c];}
                       }
                }
            google.script.run.withFailureHandler(onFailure)
                  .fillRubric(selection);
            console.log('[0][0] ' +selection[0][0]);
          }
   function onFailure(error){ alert(error.message + '  Server is not found. Try your selection again.'); }
</script>

服务器端的功能如下。。。

 function getRubric() {
// there is code here that I know works fine.  Then I make a function call.
// Locate Rubric Table
var rubricTable = findRubricTable();
if (rubricTable == null ){
    var alert = ui.alert('Server not found.  Try your selection again.');
    return;
  }
// there is more code that works.
// loadRubric is the array I send back to scriptlet that called it.
return loadRubric;
}

这个服务器函数是从getRubric()中调用的。

function findGradeTable(){
  //the code here does not call another function and works fine.  
  //It finds the correct table id number and returns it.
return rubricTable; 
}

最后,单选按钮调用该函数,该函数不调用其他函数,并对文档进行最终格式更改。

function fillRubric(selection){
//This javascript works fine.
}

收到错误后,立即查看脚本编辑器中"View"下的"Execution Transcript"。

它应该显示文件&发生异常的行号。

最新更新