为什么我的日历没有将 JSON 提要中的数据放到我的网页上?
<script type='text/javascript'>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
events: 'myfeed.php',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
eventSources: [
// your event source
{
url: '/myfeed.php', // use the `url` property
color: 'red', // an option!
textColor: 'black' // an option!
}
// any other sources...
],
eventClick: function(calEvent, jsEvent, view) {
if (!confirm("Are you sure you want to delete this?")) {
}
else
{
// remove calender, and post the info to page
$.post("mybook.php", { idnumber: calEvent.id, remove: '1' } );
$('#calendar').fullCalendar('removeEvents', [calEvent.id]);
}
}
});
});
</script>
JSON 提要 PHP 代码
<?php $arr = array('id' => '1', 'title' => 'Apples', 'start' => '1372530615', 'end' => '1372537615', 'allDay' => false);
echo json_encode($arr);
?>
Charles Web 调试器显示脚本正在评估正确的页面,并且它有响应。但是,我的日历什么也没做。:( 我认为这可能是因为我使用的是 SSL,但我已经尝试了两种方式。
将我的代码减少到
<script type='text/javascript' src='jquery-1.9.1.min.js'></script>
<script type='text/javascript' src='fullcalendar.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
events: 'myfeed.php'
});
});
</script>
JSON 提要输出
{"id":"1","title":"Apples","allDay":false,"start":"1372507615","end":"1372537615"}