我很难尝试在 fullcalendar 上填充事件,以下是我的代码,尝试从 mysql 获取数据
类 mycalendarleaves 扩展 Generic{ function calendar_LeaveDetails(){
$year = date('Y');
$month = date('m');
$this->user_id = $_SESSION['user_id'];
$params = array( ':user_id' => $this->user_id );
$stmt = parent::query("SELECT * FROM messages WHERE TYPE = 'leave' AND leave_status='approved' AND sender_id = :user_id;", $params);
while($value = $stmt->fetch()) :
$_SESSION['cal_data'] = array(
'id' => $value['id'],
'title' => $value['sender_name'],
'start' => "$year-$month-10"
);
endwhile;
}
}
echo json_encode($_SESSION['cal_data']);
$mycalendarleaves = 新的 mycalendarleaves();
这是脚本
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "calendar.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
我没有收到任何错误,日历仍然显示为空白,没有数据。我究竟做错了什么?