mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-30 11:19:57 +00:00
Fixed flash msgs on add page
This commit is contained in:
@@ -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 %}
|
||||
Reference in New Issue
Block a user