mirror of
https://github.com/marcogll/soul23_placeholder_site_server.git
synced 2026-01-13 13:25:18 +00:00
feat: Update notification form to collect name and phone and submit data via webhook, replacing Firebase email submission.
This commit is contained in:
40
js/form_submission.js
Normal file
40
js/form_submission.js
Normal file
@@ -0,0 +1,40 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#notifs-form-btn').click(function (e) {
|
||||
var name = $('#notifs-form-name').val();
|
||||
var phone = $('#notifs-form-phone').val();
|
||||
|
||||
if (name && phone) {
|
||||
var data = {
|
||||
name: name,
|
||||
phone: phone
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: 'https://flows.soul23.cloud/webhook/Ul6upjlKqQQ79rDgd8XKOm',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
success: function (response) {
|
||||
console.log("Webhook sent successfully", response);
|
||||
$("#notifs-form-btn").text("gracias :)");
|
||||
$("#notifs-form-btn").prop("disabled", true);
|
||||
alert("¡Gracias! Hemos recibido tus datos.");
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error sending webhook", error);
|
||||
var errorMessage = "Hubo un error al enviar tus datos.";
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
errorMessage += "\n" + xhr.responseJSON.message;
|
||||
} else if (xhr.responseText) {
|
||||
errorMessage += "\n" + xhr.responseText;
|
||||
}
|
||||
alert(errorMessage);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert('jejeje, lo haremos mas fácil en el futuro');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user