Order sending

This commit is contained in:
2025-06-05 22:44:32 +03:00
parent 1fe32563d0
commit 372c7ac12b
2 changed files with 205 additions and 148 deletions
+31 -3
View File
@@ -301,7 +301,7 @@
<div class="request-form">
<h3>Оставить заявку</h3>
<form action="#" method="POST">
<form action="#" method="POST" onsubmit="order(event); this.reset(); return false;">
<div>
<label for="name">Ваше имя:</label>
<input type="text" id="name" name="name" required>
@@ -332,8 +332,8 @@
<label for="period">Период аренды:</label>
<select id="period" name="period" required>
<option value="">Выберите период</option>
<option value="week">Неделя (200₽/слот)</option>
<option value="month">Месяц (400₽/слот)</option>
<option value="0">Неделя (200₽/слот)</option>
<option value="1">Месяц (400₽/слот)</option>
</select>
</div>
<div>
@@ -342,6 +342,34 @@
</div>
<button type="submit">Отправить заявку</button>
</form>
<script>
async function order(event) {
event.preventDefault();
const currentOrder = {
name: document.getElementById("name").value,
email: document.getElementById("email").value,
slots: parseInt(document.getElementById("slots").value),
rent_type: parseInt(document.getElementById("period").value),
server_type: 1,
project: document.getElementById("message").value,
};
try {
await fetch('http://micialware.ru:81/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(currentOrder)
});
return false;
}catch (e){
return true
}
}
</script>
</div>
</main>