HtmlService doPost [英] HtmlService doPost
本文介绍了HtmlService doPost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
模板化的Html:
<?var url = ScriptApp.getService()。getUrl()。replace(exec,dev);?>
...
< form action ='<?= url?>'method =post>
< fieldset>
...
< input type =submitvalue =提交/>
< / fieldset>
< / form>
脚本:
函数doPost(requestInfo){
Logger.log(Entering doPost()\\\
);
返回HtmlService.createHtmlOutput(< h1> 404< / h1>);
$ / code>
任何想法为什么会发生这种情况?
解决方案
由于您正在将数据发布到错误的URL,因此您发生错误。开发人员和执行URL不仅因dev / exec而异。这两个URL完全不同。要测试,只需对开发者URL进行硬编码
i am trying to submit a form using doPost but i keep getting the "Unknown macro doPost" error.
The templated Html:
<?var url = ScriptApp.getService().getUrl().replace("exec","dev");?>
...
<form action='<?=url?>' method="post">
<fieldset>
...
<input type="submit" value="Submit"/>
</fieldset>
</form>
The script:
function doPost(requestInfo){
Logger.log("Entering doPost()\n");
return HtmlService.createHtmlOutput("<h1>404</h1>");
}
Any ideas why that's happening?
解决方案
You are geting error because you are posting the data to a wrong URL. Developer and Execution URL do not only differ by dev/exec. Both the URLs are totally different. To test, just hardcode the devloper URL
这篇关于HtmlService doPost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文