早上好,我创建了一个json文件,它显示来自mysql的事件数据,当在浏览器中查看时,它显示的是表数据。
当我试图查看完整日历脚本时,日历会显示,但不会显示数据,我是否遗漏了什么?
xxjson-events.php
<?php require_once('Connections/ghl_portal.php'); ?>
<?php
mysql_select_db($database_ghl_portal, $ghl_portal);
$query_rsXXCal = "SELECT * FROM events";
$rsXXCal = mysql_query($query_rsXXCal, $ghl_portal) or die(mysql_error());
$row_rsXXCal = mysql_fetch_assoc($rsXXCal);
$totalRows_rsXXCal = mysql_num_rows($rsXXCal);
$result = mysql_query($query_rsXXCal) or die(mysql_error());
$arr = array();
while($row = mysql_fetch_assoc($result)){
$arr[] = $row;
}
echo json_encode($arr)
?>
<?php
mysql_free_result($rsXXCal);
?>
json.html
<script type="text/javascript">
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
theme: true,
draggable: true,
header: {
left: 'month, agendaWeek',
center: 'title',
right: 'today, prev,next'
},
editable: false,
allDayDefault: false,
url: true,
timeFormat: 'HH:mm ', // uppercase H for 24-hour clock
agenda: 'HH:mm ', // 5:00 - 6:30
events: "xxjson-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' ha sido movido ' + delta + ' diasn' + '(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
eventClick: function(calEvent, jsEvent, view) {
//alert('Event: ' + calEvent.title);
//alert('Url: ' + calEvent.url);
//alert('View: ' + view.name);
window.open(calEvent.url, blank);
return false;
}
});
});
</script>
感谢
您必须这样做,因为版本1.5
events : {url: '/xxjson-events.php'}
注意:title: start: and end :
<--这些属性必须在json数据中
还有许多可选的
参考