来自MySQL的FullCalendar数据通过JSON没有通过

时间:2012-02-20 12:33:20

标签: fullcalendar

早上好,我创建了一个显示mysql事件数据的json文件,在浏览器中查看时显示表数据ok。

当我尝试使用fullcalendar脚本查看包含此日历时,日历显示但不显示数据,我错过了什么?

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 + ' dias\n' + '(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 个答案:

答案 0 :(得分:0)

您必须这样做自版本 1.5

events : {url: '/xxjson-events.php'}

注意: title: start: and end :&lt; - 这些属性必须在您的json数据中

还有很多可选的

Reference