-
Notifications
You must be signed in to change notification settings - Fork 1
/
js.html
88 lines (59 loc) · 2.14 KB
/
js.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
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<meta charset="utf-8">
</head>
<body>
<h1>Testing sending data to the server via Javascript</h1>
<ul></ul>
<p>Edit the html file to configure the tests.</p>
<p>Confirm the signup data is in <a href="https://bigquery.cloud.google.com/" target="_blank">BigQuery</a> with the query:</p>
<pre>
#standardSQL
SELECT * FROM `gpes_en_old_api.signups` ORDER BY signed_time;
</pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
/*global jQuery, console */
jQuery.ajax({
beforeSend: function() {
console.log("Sending data...");
jQuery("ul").append("<li>Sending data...</li>");
},
url : "../index.php",
dataType: 'jsonp',
data : {
"format": "json",
"ea.campaign.id" : "2018",
"utm_medium": "test_medium",
"utm_source": "test_source",
"utm_campaign": "test_campaign",
"utm_content": "test_content",
"utm_term": "test_term",
"en_txn6": "test_gclid",
"first_name": "Test first name",
"last_name" : "Test last name",
"id_number": "y2044796w",
"email": "test9@test.com",
"phone_number": "666666666",
"postcode": "38000",
"email_ok": "Y",
"privacy": "Y"
}
}).done(function(data) {
if ( data.messages.length === 0 ) {
console.log("Confirmation received from the server");
jQuery("ul").append("<li>Confirmation received from the server.</li>");
} else { // FIXME - WHAT HAPPENS WHEN THE SERVER RESPONDS THAT NO
console.error("Error in the server response.");
jQuery("ul").append("<li>Error in the server response.</li>");
}
}).always(function() {
}).fail(function(form) {
console.error("Error sending data to the old api emulator");
jQuery("ul").append("<li>Error while sending data to the old api emulator.</li>");
});
</script>
</body>
</html>