Fixed flash msgs on add page

This commit is contained in:
2025-06-05 12:02:13 +02:00
parent 75b19f2e1b
commit b26a1905ad
2 changed files with 7 additions and 49 deletions

View File

@@ -55,34 +55,4 @@
</div>
</div>
</div>
<script>
document.getElementById('numberplateForm').addEventListener('submit', async function (e) {
e.preventDefault();
const form = e.target;
const formData = new FormData(form);
const response = await fetch(form.action || window.location.pathname, {
method: 'POST',
body: formData,
headers: { 'X-Requested-With': 'XMLHttpRequest' }
});
if (response.ok) {
const data = await response.json();
// Update the table body
const tbody = document.getElementById('numberplatesBody');
tbody.innerHTML = '';
data.plates.forEach(plate => {
tbody.innerHTML += `<tr>
<td><small class="fs-6">${plate.id}</small></td>
<td><small class="fs-6">${plate.plate}</small></td>
</tr>`;
});
form.reset();
} else {
alert('Failed to add numberplate.');
}
});
</script>
{% endblock %}