Update pages.html
Browse files- pages.html +9 -7
pages.html
CHANGED
@@ -459,7 +459,6 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
|
|
459 |
|
460 |
|
461 |
|
462 |
-
// Создаем новый тип компонента для формы
|
463 |
// Создаем новый тип компонента для формы
|
464 |
editor.Components.addType('custom-form', {
|
465 |
model: {
|
@@ -512,20 +511,23 @@ editor.Components.addType('custom-form', {
|
|
512 |
const form = this.querySelector('#contactForm');
|
513 |
form.addEventListener('submit', function(event) {
|
514 |
event.preventDefault();
|
515 |
-
const
|
516 |
-
|
|
|
|
|
|
|
|
|
|
|
517 |
if (!props.submitUrl) {
|
518 |
console.error('Submit URL is not defined');
|
519 |
return;
|
520 |
}
|
521 |
-
console.log('Form Data:', data); // Выводим данные формы в консоль
|
522 |
-
console.log('Submit URL:', props.submitUrl); // Выводим URL в консоль
|
523 |
fetch(props.submitUrl, {
|
524 |
method: 'POST',
|
525 |
headers: {
|
526 |
-
'Content-Type': 'application/
|
527 |
},
|
528 |
-
body: data
|
529 |
})
|
530 |
.then(response => response.json())
|
531 |
.then(data => {
|
|
|
459 |
|
460 |
|
461 |
|
|
|
462 |
// Создаем новый тип компонента для формы
|
463 |
editor.Components.addType('custom-form', {
|
464 |
model: {
|
|
|
511 |
const form = this.querySelector('#contactForm');
|
512 |
form.addEventListener('submit', function(event) {
|
513 |
event.preventDefault();
|
514 |
+
const data = {
|
515 |
+
name: document.getElementById('name').value,
|
516 |
+
email: document.getElementById('email').value,
|
517 |
+
phone: document.getElementById('phone').value,
|
518 |
+
options: document.getElementById('options').value,
|
519 |
+
newsletter: document.getElementById('newsletter').checked
|
520 |
+
};
|
521 |
if (!props.submitUrl) {
|
522 |
console.error('Submit URL is not defined');
|
523 |
return;
|
524 |
}
|
|
|
|
|
525 |
fetch(props.submitUrl, {
|
526 |
method: 'POST',
|
527 |
headers: {
|
528 |
+
'Content-Type': 'application/json'
|
529 |
},
|
530 |
+
body: JSON.stringify(data)
|
531 |
})
|
532 |
.then(response => response.json())
|
533 |
.then(data => {
|