我正在研究谷歌示例代码HTML 服务:与服务器功能通信 https://developers.google.com/apps-script/guides/html/communication.
我无法让示例代码适用于“Forms”。代码中是否有错误,或者是我的浏览器配置中有问题?
代码是 -
code.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function processForm(formObject) {
var formBlob = formObject.myFile;
var driveFile = DriveApp.createFile(formBlob);
return driveFile.getUrl();
}
索引.html
<script>
function updateUrl(url) {
var div = document.getElementById('output');
div.innerHTML = '<a href="' + url + '">Got it!</a>';
}
</script>
<form id="myForm">
<input name="myFile" type="file" />
<input type="button" value="Submit"
onclick="google.script.run
.withSuccessHandler(updateUrl)
.processForm(this.parentNode)" />
</form>
<div id="output"></div>
我的浏览器调试窗口中的错误是
Uncaught NetworkError: Form submission failed.
提前致谢。威尔·布朗.
此错误根本不是由于代码问题造成的,而是浏览器插件与 Google 身份验证服务之间的交互。看问题 3339 https://code.google.com/p/google-apps-script-issues/issues/detail?id=3339 and 问题 4394 https://code.google.com/p/google-apps-script-issues/issues/detail?id=4394.
如果您正在使用LastPass http://lastpass.com密码管理器插件,必须禁用它。
PS: @user3531933 - if you add your own answer, just leave a comment for me, and I'll happily delete this and leave it to you.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)