-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (95 loc) · 2.96 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My HTML Page</title>
<!-- <link rel="stylesheet" type="text/css" title="Cool stylesheet" href="style.css"> -->
<!-- Google Tag Manager -->
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-NG482KJ');
</script>
<!-- End Google Tag Manager -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NG482KJ" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div id="root">
<p></p>
</div>
<form id="test-form">
<div>
<label>Field 1</label>
<input type="text" name="firstName" value="Field 1" />
</div>
<div>
<label>Field 2</label>
<input type="text" name="lastName" value="Field 2" />
</div>
<div>
<label>Field 3</label>
<input type="text" name="middleName" value="Field 3" />
</div>
<div>
<label>Field 4</label>
<input type="text" name="parentEmail" value="Field 4" />
</div>
<div>
<button type="submit" id="submit-form">Submit</button>
</div>
</form>
<!-- jQuery -->
<script src="main.js" type="text/javascript"></script>
<!-- jQuery -->
<script type="text/javascript">
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
var $form = $('form#test-form'),
url = 'https://script.google.com/macros/s/AKfycbxF5Xe80oCQj7IWdBNmQCvVsXLXHevpfTisLK7t_0vbAh_NkvNT/exec'
$('#submit-form').on('click', function(e) {
e.preventDefault();
// console.log($form.serializeObject())
var jqxhr = $.ajax({
url: url,
method: "GET",
dataType: "json",
data: $form.serializeObject(),
success: function(data, status, xhr) { // success callback function
$('p').append(data).append("<b>Appended text</b>");
console.log(data, status);
},
error: function(jqXhr, textStatus, errorMessage) { // error callback
$('p').append('Error: ' + errorMessage);
console.log(textStatus, errorMessage)
}
})
})
</script>
</body>