Flatlogic Bot 3ca1bd5b55 v1
2026-01-22 14:21:55 +00:00

51 lines
1.4 KiB
JavaScript

$(document).ready(function() {
$('#subscribeForm').on('submit', function(e) {
e.preventDefault();
const $form = $(this);
const $btn = $form.find('button');
const originalBtnText = $btn.text();
$btn.prop('disabled', true).text('Processing...');
$.ajax({
url: 'subscribe.php',
method: 'POST',
data: $form.serialize(),
dataType: 'json',
success: function(response) {
showNotification(response.message);
if (response.success) {
$form[0].reset();
}
},
error: function() {
showNotification('An unexpected error occurred.');
},
complete: function() {
$btn.prop('disabled', false).text(originalBtnText);
}
});
});
function showNotification(message) {
const $notif = $('#notification');
$notif.text(message).fadeIn();
setTimeout(function() {
$notif.fadeOut();
}, 5000);
}
// Smooth scroll for anchor links
$('a[href^="#"]').on('click', function(e) {
e.preventDefault();
const target = this.hash;
if (!target) return;
$('html, body').animate({
scrollTop: $(target).offset().top - 80
}, 500);
});
});