我正在为文档创建Google插件。所以我使用的是html,scriptlets和java。一切都运行良好,但突然间,我收到了这个错误,我不知道如何解决它。
当我运行html时,会出现错误,如表中所示。在Developer Tools中,显示以下错误: 1. Google Apps脚本:回调函数不支持此操作。 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.
}
答案 0 :(得分:0)
在收到错误后立即查看脚本编辑器中“视图”下的“执行脚本”。
它应显示文件&amp;发生异常的行号。