Skip to content

Instantly share code, notes, and snippets.

@rememberlenny
Last active April 21, 2021 21:30
Show Gist options
  • Save rememberlenny/9de4fdeb5c487ba020fb to your computer and use it in GitHub Desktop.
Save rememberlenny/9de4fdeb5c487ba020fb to your computer and use it in GitHub Desktop.
How to post to Google docs using a jQuery ajax POST request
// url is the link for the form view page
// data is the name attribute of the field
$.ajax({
url: "https://docs.google.com/forms/d/1iqMixtVq4O0AFvYCZHbGerigi1G5Qb3XthXZX9VpNtk/formResponse",
data: { "entry.1679407376": field1},
type: "POST",
dataType: "xml",
statusCode: {
0: function() {
//Success message
},
200: function() {
//Success Message
}
}
});
var request = new XMLHttpRequest();
var d = new Date();
var n = d.getTime();
var url = 'https://docs.google.com/forms/d/1FhRXyqVohna2IdThVwONXLAAGW4f6Ioy46BR2MRZy68/formResponse';
var data = { "entry.993789377": n};
request.open('POST', url, true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send(data);
@bitttttten
Copy link

bitttttten commented Sep 15, 2020

Running into the same issue as @shamshul2007

When you explicitly "collect email addresses" then there is no "entry.x" id on the form. It looks like google form is using "emailAddress" as the name, although this doesn't work when I send emailAddress as the key.

Did you find out a solution @shamshul2007?

@TanimSk
Copy link

TanimSk commented Apr 21, 2021

after creating form click three dots> go to get prefilled link>then inspect
you will get the input fields name

@rememberlenny
Copy link
Author

I'm surprised people still use this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment