first commit
This commit is contained in:
commit
008070e8d3
32
0cd.xyz-post.js
Normal file
32
0cd.xyz-post.js
Normal file
@ -0,0 +1,32 @@
|
||||
async function post() {
|
||||
let formData = new FormData();
|
||||
var success = document.getElementById("success")
|
||||
var warning = document.getElementById("warning")
|
||||
var danger = document.getElementById("danger")
|
||||
success.hidden=true
|
||||
warning.hidden=true
|
||||
danger.hidden=true
|
||||
formData.append("email", document.getElementById("email").value);
|
||||
formData.append("message", document.getElementById("message").value);
|
||||
let response = await fetch("contact/form", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
});
|
||||
if (response.ok) {
|
||||
success.hidden=false
|
||||
success.textContent="Message sent, we'll get back to you as soon as possible"
|
||||
document.getElementById("email").value=""
|
||||
document.getElementById("message").value="";
|
||||
} else {
|
||||
if (response.status == 400) {
|
||||
let json = await response.json();
|
||||
if (json) {
|
||||
danger.hidden=false
|
||||
danger.textContent=json
|
||||
}
|
||||
} else {
|
||||
warning.hidden=false
|
||||
warning.textContent="Unable to send, please try again later"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user