-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (37 loc) · 1023 Bytes
/
Copy pathscript.js
File metadata and controls
43 lines (37 loc) · 1023 Bytes
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
$(function() {
//on submit, call submitForm() function
$("#contactForm").submit(function(event) {
event.preventDefault();
submitForm();
});
//function that handles AJAX call to PHP file
let submitForm = () => {
let name = $("#name").val();
let email = $("#email").val();
let subject = $("#subject").val();
let message = $("#message").val();
$.ajax({
type: "POST",
url: "./contact.php",
data: {
name: name,
email: email,
subject: subject,
message: message,
captcha: grecaptcha.getResponse()
},
success: function(text){
if (text == "Recaptcha Success, Mail Sent Successfully") {
//You can delete the console.logs if youre satisfied it works fine
console.log("Mail Sent :" + text);
formSuccess();
} else {
console.log("Mail Send Failure :" + text);
}
}
});
};
let formSuccess = () => {
$("#msgSubmit").removeClass("hidden");
};
});