-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.html
49 lines (49 loc) · 1.88 KB
/
widget.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>
<title>Subscriber to Newsletter</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#subnewsletterform").submit(function(e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
var form = $(this);
var actionUrl = form.attr('action');
jQuery.ajax({
type: "POST",
url: actionUrl,
data: form.serialize(), // serializes the form's elements.
cache: false,
success: function(data) {
console.log(data); // show response from the php script.
jQuery("#subnewsletterform").trigger("reset");
jQuery('#resmsg').show();
},
error: function (jqXHR, exception) {
console.log(jqXHR);
}
});
});
});
</script>
</head>
<body>
<div class="container">
<h2>Subscriber to Newsletter</h2>
<form id="subnewsletterform" action="submit.php">
<div class="form-group">
<label for="email">Your Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter your email" name="email">
</div>
<button type="submit" class="btn btn-default">Subscribe</button>
<div id="resmsg" class="alert alert-success" style="display: none;">
<strong>Success!</strong> Thanks for subscribing.
</div>
</form>
</div>
</body>
</html>