我正在尝试将发布请求数据保存到 Google 电子表格中。但是,数据保存为未定义。
原帖使用了表单并使用了jquery。请参阅下面的链接。但我试图在不使用 jquery 的情况下传递数组。
我正在使用以下应用程序脚本,而不使用 jquery - https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
我在这里发布代码。
function sendData(data) {
var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
var theUrl = "spreadsheeturl";
xmlhttp.open("post", theUrl);
//xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.send(JSON.stringify(data))
}
最佳答案
我找到了答案,如果要传递 JSON 数据,则必须取消注释应用程序脚本中的 block 。
关于javascript - 在 JavaScript 中将数据插入 Google 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55623414/