请输入您的查询条件,我们将为您提供最优惠的价格。
<script> document.querySelector('form').addEventListener('submit', function (e) {e.preventDefault();const city = document.querySelector('city').value;const checkin = document.querySelector('checkin').value;const checkout = document.querySelector('checkout').value;const adults = document.querySelector('adults').value;const children = document.querySelector('children').value;if (!city || !checkin || !checkout) {alert('请填写所有必填字段。');return;}// 发送 AJAX 请求来获取宾馆价格const xhr = new XMLHttpRequest();xhr.open('GET', `${city}&checkin=${checkin}&checkout=${checkout}&adults=${adults}&children=${children}`);xhr.onload = function () {if (xhr.status === 200) {const data = JSON.parse(xhr.responseText);// 在结果容器中显示宾馆价格let output = '';data.forEach(hotel => {output += `宾馆名称:${hotel.name}
价格:${hotel.price} 元/晚
剩余客房:${hotel.availability}
预订