forked from jamiewilson/form-to-google-sheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration-sample
18 lines (16 loc) · 922 Bytes
/
integration-sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/formdata.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/promise-polyfill/8.2.0/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/fetch.umd.min.js"></script>
<script>
window.addEventListener('load', function () {
const scriptURL = "https://script.google.com/macros/s/AKfycbzCnjjp7oCERDOx-VSsPCUMQ98Nv1thEO3z_AmKogJRiu_IByABhlWOCRqQwJFHvPkL/exec"
const form = document.querySelector('form#wh-user-data-form')
document.querySelector('button.btn').addEventListener('click', e => {
e.preventDefault()
fetch(scriptURL, { method: 'POST', body: new FormData(form)})
.then(response => console.log('Success!', response, form))
.catch(error => console.error('Error!', error.message))
})
})
</script>