我喜欢使用 Ajax 调用检索字符串,但我在响应中不断获取整个 html 页面。
检索字符串的方法是什么?
$.ajax({
url: '{$domainpath}{$language}/reservations/updatestartdates',
data: {property:property,stayduration:stayduration},
type: 'POST',
dataType: 'json'
}).done(function(response){
alert(response);
});
private function updateAvailableStartDates(){
if(isset($_POST['property']) && !empty($_POST['property']) && isset($_POST['stayduration']) && !empty($_POST['stayduration'])){
$property = $_POST['property'];
$stayduration = $_POST['stayduration'];
}
//handle code
echo json_encode('only this string');
}