我有jquery datepicker,它通过来自数据库的ajax调用选择日期时给出事件列表..当我点击结果在15秒后显示得太晚的日期...可以任何1建议我该做什么快速点击获得结果: -
var x = '';
$('#calendar').datepicker({
altField: '#datepicker_send',
inline: true,
firstDay: 1,
showOtherMonths: true,
altFormat: "yy/mm/dd",
dateFormat: "yy/mm/dd",
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
onSelect: function (dateText) {
$('#event-date').text(dateText)
x = dateText;
//alert(x);
$.ajax({
type: "GET",
url: 'check_events.php',
data: 'y=' + x,
success: function (data) {
$('#event-date1').html(data); //Alert Data on success not result.
// alert(data);
}
});
}
});
Check_events.php:-``
<? php
if (isset($_GET['y'])) {
$y = $_REQUEST['y'];
$sql_check = mysql_query("SELECT * FROM events WHERE date='$y'");
$res = mysql_num_rows($sql_check);
if ($res == 0)
{
echo '<div class="evnt_name"><a href="#">No Events For Today <a/> </div>';
} else
{
while ($rec = mysql_fetch_assoc($sql_check))
{
?>
< div > Some Result < /div>
<?php }
}
}
exit; ?>
答案 0 :(得分:0)
我认为@JLevett建议在mysql连接字符串中将主机名从localhost更改为127.0.0.1。还要在select查询中指定字段名称而不是*,它在性能方面没有太大改进,但它会有所帮助。