如何将表单数据发布到Google Apps脚本

问题描述:

将表单数据从我的HTML页面发布到我的GAS脚本的最佳/最简单的方法是什么?如何将表单数据发布到Google Apps脚本

$(document).ready(function() { 
    $.getJSON(SCRIPT_URL+"?callback=?", { method:"addRow"}, function (data) { alert(JSON.stringify(data)); }); 
}); 
+0

$(文件)。就绪(函数(){$ .getJSON(SCRIPT_URL +,{ 方法 “回调=?”: “addRow”}, 功能(数据){ 警报(JSON.stringify(数据)); }); }); 我在doPost/doGet的文档中收到404(OK)错误 – Rover

+0

Lppk。看看contentService。回来的代码,我们会帮助。 –

+0

第二次尝试,但现在得到:Origin'null'因此不被允许访问。响应有HTTP状态代码404 我的权限是所有公共 '函数writeToSpreadSheet(POSTDATA回调){$ .post的(在scriptUrl,POSTDATA,功能(RESP){ 回调(RESP); }); }' – Rover

如果您正在使用Apps Script HTML Service,则可以使用google.script.run

Google Documentation - Client-side API - call server-side Apps Script functions

从谷歌之外的应用程序或网站,做一个HTTP请求到Google Apps脚本的网址。