[wpcode id=”46207″]
var endDate = document.getElementById(‘end-date’).value; var helpType = document.getElementById(‘help-type’).value; // Display a loading message while processing the request document.getElementById(‘result’).innerHTML = ‘Generating your travel plan…’; // Send the form data via AJAX to the backend fetch(‘‘, { method: ‘POST’, headers: { ‘Content-Type’: ‘application/x-www-form-urlencoded’, }, body: new URLSearchParams({ action: ‘generate_travel_plan’, // Your backend action destination: destination, start_date: startDate, end_date: endDate, help_type: helpType }) }) .then(response => response.json()) .then(data => { // Display the AI response document.getElementById(‘result’).innerHTML = `${data.message}
`; }) .catch(error => { console.error(‘Error:’, error); document.getElementById(‘result’).innerHTML = ‘Sorry, there was an error processing your request.
‘; }); }); });