2024-08-31 13:06:03 +00:00
|
|
|
document.getElementById('applicationForm').addEventListener('submit', function(event) {
|
2024-11-14 13:53:04 +00:00
|
|
|
event.preventDefault();
|
2024-08-31 13:06:03 +00:00
|
|
|
|
|
|
|
// Get form data
|
|
|
|
const formData = new FormData(this);
|
|
|
|
const data = Object.fromEntries(formData.entries());
|
|
|
|
|
2024-11-14 13:53:04 +00:00
|
|
|
// Send form data to server-side endpoint
|
|
|
|
fetch('/submit', {
|
2024-08-31 13:06:03 +00:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
body: JSON.stringify(data),
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(result => {
|
|
|
|
console.log('Success:', result);
|
2024-11-14 13:53:04 +00:00
|
|
|
document.body.innerHTML = '<h2>Thank you for your application!</h2>';
|
2024-08-31 13:06:03 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error:', error);
|
|
|
|
});
|
|
|
|
});
|