簡體   English   中英

在JavaScript中將數據插入Google表格

[英]Insert data to Google sheets in javascript

我正在嘗試將發帖請求數據保存到Google電子表格。 但是,數據另存為未定義。

原始帖子使用表單並使用jquery。 請參閱下面的鏈接。 但是我也嘗試不使用jquery傳遞數組。

我正在使用以下應用程序腳本而不使用jquery- https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-與-Ajax的例子/

我在這里發布代碼。

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數據,則必須取消注釋應用程序腳本中的塊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM