我试图使用HTMLService来管理简单的表单。这是一个原型HTML表单(NATIVE选项用于可移植性):
form.gs
function htmlTest (){
var html = HtmlService.createHtmlOutputFromFile('form');
html.setSandboxMode(HtmlService.SandboxMode.NATIVE);
SpreadsheetApp.getUi().showModalDialog(html, "Sample Form");
}
function cBack (el1, el2){
Browser.msgBox('Data sent');
Logger.log(el1);
Logger.log(el2);
}form.html
Enter field 1: <input name="name1" id='input1'>
<br>
Enter field 2: <input name="name2" id='input2'>
<br>
<input type='button' value='Submit' onclick='fParser()'>
<script>
function fParser() {
var el1=document.getElementById('input1').value;
console.log(el1);
var el2=document.getElementById('input2').value;
console.log(el2);
google.script.run.cBack(el1, el2);
google.script.host.close();
}
</script> 如何有效地调试从服务HTML触发的回调?
当回调没有启动时,该怎么办?
我看到,有时只是关闭和重新打开文档来解决问题:是否有更有效的方法来重新加载代码?
发布于 2015-01-16 10:49:23
我发现调试HTML页面中的所有内容更容易,可以使用withSuccessHandler返回变量。通过这种方式,您可以继续编辑.gs并单击按钮,在控制台上获得新的结果。
例如:
google.script.run.withSuccessHandler(debugging).cBack(el1, el2);
google.script.run.withSuccessHandler(debugging).anotherCallBacl(el);
function debbugging( logs ){
console.log( logs );
}.gs:
function cBack (el1, el2){
Browser.msgBox('Data sent');
return "el1 : " + el1 + " - el2: " + el2;
}https://stackoverflow.com/questions/27974548
复制相似问题