简体   繁体   中英

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 . It's supposed to take in a form submission and transfer the data to a google sheet. 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. 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). 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):

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

and this (the new 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. They're specific to google script so will not work outside of it.

Disabling them made the form work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM