0

I'm trying to save a post request data to a google spreadsheet. However, the data is saved as undefined.

The original post uses a form and uses jquery. See the link below. But I'm trying to pass an array also without the use of jquery.

I'm using the following app script without using jquery - https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/

I'm posting the code here.

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))
    }

1 Answer 1

1

I found the answer, you have to uncomment a block in the app script if you are passing JSON data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.