GP | fix: починил форму + скрытое хранение кридов
This commit is contained in:
@@ -28,29 +28,20 @@ const CHAT_ID = '';
|
||||
[...modalForms, ...callbackForms].forEach((form) => {
|
||||
form.addEventListener('submit', (event) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const name = formData.get('name');
|
||||
const phone = formData.get('phone');
|
||||
const formData = new FormData(event.currentTarget); // автоматически формирует объект с полями и значениями
|
||||
formData.append('act', 'order'); // добавляем поле для проверки на бекенде
|
||||
|
||||
// const name = formData.get('name');
|
||||
// const phone = formData.get('phone');
|
||||
// const message = `Имя: ${name} Телефон ${phone}`;
|
||||
// sendMessage(message);
|
||||
|
||||
event.currentTarget.reset();
|
||||
fetch('../../send.php', {
|
||||
method: 'POST',
|
||||
data: { name, phone },
|
||||
cache: 'no-cache',
|
||||
body: formData,
|
||||
});
|
||||
if (callbackModal) callbackModal.classList.remove('active');
|
||||
if (thanksModal) thanksModal.classList.add('active');
|
||||
});
|
||||
});
|
||||
|
||||
// function sendMessage(message) {
|
||||
// const url = `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&parse_mode=html&text=${message}`;
|
||||
|
||||
// fetch(url)
|
||||
// .then((data) => {
|
||||
// console.log('Message sent successfully:', data);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error('Error sending message:', error);
|
||||
// });
|
||||
// }
|
||||
});
|
||||
Reference in New Issue
Block a user