22 lines
665 B
JavaScript
22 lines
665 B
JavaScript
document.getElementById('searchForm').addEventListener('submit', function(event) {
|
|
event.preventDefault();
|
|
|
|
// Serialize the form data
|
|
var formData = new FormData(this);
|
|
|
|
// Perform the AJAX request to the server
|
|
fetch('search_hotels.php', {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(hotels => {
|
|
// Process the returned hotel data
|
|
console.log(hotels); // For debugging purposes
|
|
// You will need to write code to display the hotels on the page
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
});
|