12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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 = `
- <user>
- <name>${name}</name>
- <phone>${phone}</phone>
- <email>${email}</email>
- <code>${code}</code>
- <password>${password}</password>
- </user>
- `;
- // Отправляем 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';
- }
|