简体   繁体   English

我的“包含”如何在独立的Google Apps脚本中破坏表单提交?

[英]How are my “Includes” breaking the form submission in a Standalone Google Apps Script?

I've been using this script to create this web app . 我一直在使用此脚本来创建此Web应用程序 It's supposed to take in a form submission and transfer the data to a google sheet. 应该以表单提交的形式将数据传输到Google工作表。 Once it's done that, it should clear the fields and start over. 完成后,应清除字段并重新开始。 This one works (for the most part). 这一工作(大部分情况下)。

I tried to clean up the script by adding includes in the Code.gs file. 我试图通过在Code.gs文件中添加include来清理脚本。 Once I changed the script to this to create the same web app, I get this as a result (you have to actually submit something to see it). 将脚本更改为此以创建相同的Web应用程序后, 我得到了这个结果(您必须提交一些内容才能看到它)。 Once you click submit, nothing runs, and the page switches to some crazy web address. 单击提交后,任何内容都不会运行,并且页面会切换到一些疯狂的网址。

I'm pretty sure the problem is the difference between this (the original Code.gs): 我很确定问题是这两者之间的区别(原始Code.gs):

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('Index')
            .setSandboxMode(HtmlService.SandboxMode.NATIVE);
}

and this (the new Code.gs): 这(新的Code.gs):

function doGet(request) {
  return HtmlService.createTemplateFromFile('Index')
      .evaluate()
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename)
      .getContent();
}

I just don't know enough to see the problem. 我只是不了解该问题。

You're using Logger.log() statements inside the javascript tags. 您正在javascript标记内使用Logger.log()语句。 They're specific to google script so will not work outside of it. 它们特定于Google脚本,因此无法在其外部运行。

Disabling them made the form work. 禁用它们使表格起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Google Apps脚本解析表单提交 - Parse Form Submission with Google Apps Script Google Apps脚本:已提交的邮件内容(表单提交脚本) - Google Apps Script: Message Content As Is submitted (Form Submission Script) 如何使提交功能在使用 Google Apps 脚本创建并嵌入 Google 站点的 Web 表单中工作? - How to make submission function work in a web form that is created using Google Apps Script and embedded in a Google Site? Google Apps脚本未上传文件:NetworkError:提交表单失败 - Google Apps Script Not Uploading File: NetworkError: Form Submission Failed 谷歌应用程序脚本。 表单提交随机失败 - Google apps script. Form submission fails randomly 在 Google Apps 脚本中,如何通过重新加载 doPost() 返回的 HTML 来防止多次提交表单数据? - In Google Apps Script, How to prevent multiple submission of form data by reloading the HTML returned by doPost()? 如何将值从HTML表单提交传递给Google表格,然后再传递回Google Apps Script Web App中的HTML - How do I pass a value from an HTML form submission to a Google Sheet and back to HTML in a Google Apps Script Web App Google Apps脚本:通过Google表单提交在Google云端硬盘中创建文件夹 - Google Apps Script: Creating a folder in Google Drive from a Google Form submission 嵌入的Google地图破坏了我的联系表单检查脚本 - Embeded Google map is breaking my contact form checking script 使用 Google Apps 脚本将文件上传到我的 google 驱动器(在 GOOGLE 中没有表格) - Upload file to my google drive with Google Apps Script (NO FORM IN GOOGLE)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM