-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (46 loc) · 1.38 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mailchimp</title>
</head>
<body>
<h3>Subscribe</h3>
<form id="form">
<input type="email" name="email" placeholder="Email">
<input type="text" name="fname" placeholder="Name">
<input type="submit" value="Enviar">
</form>
<span id="message" style="display: none;">
<h3></h3>
</span>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
const $form = document.getElementById('form');
const syncMailchimp = (event) => {
event.preventDefault();
// console.log('hola mundo');
const data = new FormData($form);
const email = data.get('email');
const fname = data.get('fname');
$.post('http://localhost/mailchimp/mailchimpApi.php', { email: email, fname: fname }, (data, status) => {
console.log(data);
// console.log(status);
if (status == 'success') {
$('#message').show();
if (data == 200) {
$('#message h3').text('Thanks for subscribing');
$('#form').hide();
} else {
$('#message h3').text('Algo salio mal');
}
} else {
$('#message').show();
$('#message h3').text('Algo salio mal');
}
});
}
$form.addEventListener('submit', syncMailchimp);
</script>
</body>
</html>