谷歌的onSuccessHandler没有响应

时间:2020-01-28 23:04:55

标签: javascript google-apps-script google-sheets handler

我已经在链接到Google电子表格的html文件中编写了一个javascript。 一切正常,脚本执行所需的工作,从html中获取某些值并将其填充到工作表中的某些字段中,但是没有返回成功消息,并且用户被引导到空白页面。

您知道如何解决此问题吗?

HTML代码:

<script>
function onSuccess() {window.confirm("Your order was successfully sent");}
function onFailure() {window.confirm("Something went wrong. Please try again or contact the Customer Service.");}

function PR(){
if (window.confirm("Send Order?")) {

var k = document.getElementById('custname').value;
var l = document.getElementById('mayor').value;
var m = document.getElementById('ioc').value;
var n = document.getElementById('canpen').value;
var o = document.getElementById('date').value;
var p = document.getElementById('idcie').value;
var q = document.getElementById('totdes').value;

google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).copyData(k,l,m,n,o,p,q);

} 
else {alert("You canceled your order, try again!");}
}

</script>

GOOGLE脚本:

function doGet(request) {
  return HtmlService.createTemplateFromFile('page')
      .evaluate();
      
}


function copyData(k,l,m,n,o,p,q) {
DB.getRange(1,3).setValue(l);
DB.getRange(1,4).setValue(m);
DB.getRange(1,5).setValue(p);
DB.getRange(1,6).setValue(n);
DB.getRange(1,7).setValue(o);
DB.getRange(1,8).setValue(q);

}

0 个答案:

没有答案
相关问题