-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.js
30 lines (29 loc) · 827 Bytes
/
contact.js
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
"use strict";
const form = document.getElementById("ajax-contact");
form.addEventListener("submit", function(e) {
e.preventDefault();
fetch("https://api.admin.tik.website/feedbacks/notify", {
method: "POST",
redirect: "manual",
credentials: "omit",
refer: "",
body: JSON.stringify({
target: 'Contact Site',
subject: "Feedback at " + location.hostname + location.pathname,
from: form.email.value,
name: form.nm.value,
to: "[email protected]",
message: form.message.value,
}),
headers: {
"Content-Type": "application/json",
},
}).then(() => {
form.reset();
form.querySelector(".contact-success").classList.add("shown");
setTimeout(
() => form.querySelector(".contact-success").classList.remove("shown"),
3000
);
});
});