Firebug显示数据流但不显示日历?

时间:2012-02-24 13:53:27

标签: mysql json fullcalendar

很多天后[9]我已经到了需要寻找另一个日历或者只是放弃的地方..使用fullcalendar我有json-events.php将mysql数据发送到我的staff_calendar.php页面,数据流显示在firebug中,日历显示在页面中但数据没有出现在实际的完整日历中,有人可以帮忙吗?

什么可以阻止我的页面中的数据呈现?

xxjson-events.php

<?php
mysql_select_db($database_ghl_portal, $ghl_portal);
$query_rsXXCal = "Select events.* , UNIX_TIMESTAMP(start_date) as start_date, UNIX_TIMESTAMP(end_date) as end_date 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());

        while($row = mysql_fetch_assoc($result)){
             $eventsArray = array();
             $eventsArray['title'] = $row['title'];
             $eventsArray['start'] = $row['start_date'];
             $eventsArray['end'] = $row['end_date']; 
        }  

        header('Content-type: application/json');

        echo json_encode($eventsArray)
?>

这将在浏览器和输出中输出萤火虫:

{"title":"Visit","start":"1330077690","end":"1330081890"}

calendar.php

script type='text/javascript'>

$(document).ready(function() {
    $('#calendar').fullCalendar({
        editable: false,
        eventSources: [
        {
            url: '/xxjson-events.php',
            async: 'false' // No longer asynchronous
        }
    ],
        loading: function(bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        }
    }); });

</script>

感谢任何能够对此有所了解的人,不管它多么小!

2 个答案:

答案 0 :(得分:0)

首先我怀疑是因为

async: 'false'

应该......

async: false

并且默认情况下allDayDefault设置为true,因此如果您没有显示allDay事件,那么您实际上不会看到它们。

如果您不想显示allDay事件,请添加...

allDayDefault: false

...到初始化。另一方面,如果您确实要显示allDay事件,则需要在数据库表中添加另一个名为allDay的字段,并根据事件所要求的内容将其设置为true或false。通过阵列将其拉出来,它应该显示出来。如果这有帮助,请告诉我。

答案 1 :(得分:0)

我有它!因此,fullcalendar解析器没有错误。我虽然JSON是一个标准......不幸的是它不是(仅在我的情况下可能:P)。 因此,来自servlet的JSON响应如下所示:

{"id":"68","title":"ddd","start":"2012-03-28","end":"2012-03-29"}

我只是在从servlet发送之前添加“[”和“]”,它可以工作!

[{"id":"68","title":"ddd","start":"2012-03-28","end":"2012-03-29"}]

我希望对像我这样的人有所帮助; - )