1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-19 17:03:01 +05:30

(feat): implemented basic form submission

This commit is contained in:
2023-12-10 18:57:50 +05:30
parent f86b294bc1
commit 2c51a048f6
2 changed files with 60 additions and 3 deletions

View File

@@ -13,15 +13,43 @@ $(document).ready(function() {
let name = nameInput.value;
let email = emailInput.value;
let message = emailInput.value;
let message = messageInput.value;
let recaptchaValue = grecaptcha.getResponse();
if(name !== "" && email !== "" && message !== "") {
if(recaptchaValue !== "") {
let formData = {
name: name,
email: email,
message: message,
recaptcha: recaptchaValue
};
$(sendBtn).html("Sending....");
$.ajax({
url: 'core/handle_contact.php',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(formData),
success: function(response) {
if (response.alert && response.alertType) {
console.log(response.alert);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
},
complete: function() {
$(sendBtn).html("SEND <i class='fa-regular fa-paper-plane ml-2'></i>");
console.log("completed");
}
});
}
else {
show_alert("Please check-in reCaptcha", "info")
show_alert("Please check-in reCaptcha", "info");
}
}
else {