./gradlew connectedDevelopmentDebugAndroidTest
我正在尝试在DIV #txtHint中显示datepicker发布数据。它工作,但它将整页html发布到这个div。我只希望在<?php
if(isset($_POST['date'])) {
$date = strtotime($_POST['date']);
$day = strtolower(date("D", $date));
}
?>
<script>
$(function() {
$( "#datepicker" ).datepicker($.extend({
constrainInput: true,
altField: ".alternate",
altFormat: "yy-mm-dd",
minDate: 0,
firstDay: 1,
onSelect:function(dateText,instance) {
$.post("index.php", { date:dateText },
function(data) {
$('#txtHint').html('');
$('#txtHint').html(data);
});
}
},
));
});
</script>
这是index.php:
<div id="txtHint"></div>
我特别希望它在一个页面中。没有为帖子数据调用外部脚本。 有人可以建议吗?
答案 0 :(得分:1)
更改index.php
以便在响应AJAX请求后退出,并且不会打印完整的HTML文件。
<?php
$today = strtotime(date("d-m-Y"));
$now = strtotime(date("H:i"));
$before = "-".$settings['close_before']." hours";
if(isset($_POST['date'])) {
$date = strtotime($_POST['date']);
$day = strtolower(date("D", $date));
// THIS HERE SHOULD BE RETURNED TO TXTHINT DIV BELOW IN FORM
echo "<select name=\"time\" class=\"form-control\" disabled>";
echo "<option value=\"\">".$day."</option>";
echo "</select>";
exit(); // <<=== Add this
}
?>