如何找到“操作”位置在代码中? '回调函数不支持此操作'。
我正在为文档创建Google插件。所以我使用html,scriptlets和java。一切都运行正常,但突然,我得到这个错误,我不知道如何解决它。
I'm creating a Google addon for docs. So I'm using html, scriptlets and java. Everything has run fine, but suddenly, I'm getting this error and I don't know how to solve it.
当我运行html,错误出现,如表所示。在开发人员工具中,显示以下错误:
1. Google Apps脚本:回调函数不支持此操作。
2.给定范围不属于当前选择的文档。
3. G.Y0
When I run the html, the error comes up, as shown in the table. Within Developer Tools, the following errors are shown: 1. Google Apps Script: This operation is not supported from a callback function. 2. The given range does not belong to the current selection's document. 3. G.Y0
如何使用这些信息来查找错误的位置?
How do I take this information to find the location of the error?
每个请求的其他信息........
ADDITIONAL INFORMATION per request........
很抱歉,我使用的是javascript。
Sorry, I'm using javascript.
我的html文件只有两个服务器端函数调用。第一个是通过一个scriptlet,它在加载html之前加载。此调用函数返回一个数组,用于为表创建动态html的边栏。
My html file has only two server side function calls. The first is via a scriptlet, which loads prior to loading the html. This call function returns an array used to create a sidebar with dynamic html for a table.
<? var rubric = getRubric(); ?>
第二个,一个按钮,在侧边栏。该按钮存储位于侧边栏中的单选按钮ID,然后将其发送到服务器端功能。我放了一个withFailureHandler。
The second, a button, is in the sidebar. The button stores radio button ids located in the sidebar and then sends them over to the server-side function. I placed a withFailureHandler on it.
<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>
服务器端功能看起来像这样...
The server side functions look like this...
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
This server function is called from within the 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;
}
最后,单选按钮调用此函数,不调用其他函数
Lastly, the radio button calls this function which does not call other functions and makes the final format changes on the document.
function fillRubric(selection){
//This javascript works fine.
}
脚本编辑器中的视图下,在收到错误后立即。
Look at the "Execution Transcript" under "View" in the Script Editor, immediately after receiving the error.
它应该显示文件&发生异常的行号。
It should show the file & line number where the exception occurred.