const registrationForm = document.getElementById('registrationForm'); registrationForm.addEventListener('submit', (event) => { event.preventDefault(); const name = document.getElementById('name').value; const phone = document.getElementById('phone').value; const email = document.getElementById('email').value; const code = document.getElementById('code').value; const password = document.getElementById('password').value; // Создаем объект XML для записи данных const xml = ` ${name} ${phone} ${email} ${code} ${password} `; // Отправляем XML-данные на сервер fetch('http://localhost:8000/save_user', { method: 'POST', headers: { 'Content-Type': 'text/xml; charset=utf-8' }, body: xml }) .then(response => { if (!response.ok) { throw new Error('Ошибка при отправке данных на сервер'); } return response.text(); }) .then(data => { console.log('Ответ от сервера:', data); document.getElementById('successPopup').style.display = 'block'; registrationForm.reset(); }) .catch(error => { console.error('Ошибка:', error); }); }); // Функция для закрытия всплывающего окна function closePopup() { document.getElementById('successPopup').style.display = 'none'; }