-
Notifications
You must be signed in to change notification settings - Fork 0
/
testformresponsefetchwithproxy.html
46 lines (33 loc) · 1.08 KB
/
testformresponsefetchwithproxy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<body>
<h2>The Button Element</h2>
<form id="myForm">
name <input type="text" name="entry.1492703236">
<button type="button" onclick="sendForm()">Click Me!</button>
</form>
<script>
async function sendForm() {
// First turn submit button into progress button.
document.getElementById("submitButton").innerHTML = "Progress";
/* ALL GOOD! :D
// this allows us to bypass cors
// todo: check if this site is running if not use another, if not, go experimental mode
var url = "https://cors-anywhere.herokuapp.com/"
// now add the destination url
url += "https://docs.google.com/forms/d/e/1FAIpQLSeBzokJL941yd1cK6EpZZAfNr_4UjUTi-irPZdsHYHK0ksAug/formResponse";
// Parse formData for use in fetch()
var formData = new FormData(document.getElementById("myForm"));
var data = new URLSearchParams();
for (const pair of formData) {
data.append(pair[0], pair[1]);
}
// send off the data!
const resp = await fetch(url, {method: 'post', body: data});
//resp.status = 200; is good. all else is faliure
await console.log(resp.status);
*/
}
</script>
</body>
</html>