【问题标题】:FullCalendar jquery json Events MySQL ProblemFullCalendar jquery json 事件 MySQL 问题
【发布时间】:2010-11-24 11:58:36
【问题描述】:

我遇到了无法在日历中显示事件的问题,我现在不知道为什么...日期格式是正确的...如果我尝试使用 json 中的正常事件...我的意思是使用演示中的示例事件...它工作正常...但是如果从我的 MSQL 中获取我的事件我永远不会看到一个事件

这是来自 SQl Satemaent 和数组创建的代码

while($res = mysql_fetch_assoc($result)){
  $start = $res['start'];
  $end = $res['end'];
  $title = $res['title'];
  $eventStart = ($start/1000);
  $eventEnd = ($end/1000);
  $rows[] = array(
        'id'        => $res['id'],
        'title'     => $title,
        'start'     => str_replace("+00:00", " +01:00",date('c',$eventStart)),
        'end'       => str_replace("+00:00", " +01:00",date('c',$eventEnd)),
        'allDay'    => false,
     );
}
return $rows;

这里是 json.php

$arrEvents = getView(($_REQUEST['start']*1000), ($_REQUEST['end'])*1000);
var_dump($arrEvents);
echo json_encode($arrEvents);

这是结果:

[{"id":"10","title":"Urlaub","start":"2010-11-24T07:30:00+01:00","end":"2010-11-24T16:15:00+01:00","allDay":false}]

所以如果有人可以帮我或提示我如何修复这个错误......我很高兴

谢谢

【问题讨论】:

  • 您是否收到任何 JavaScript 错误?你的 JS 长什么样子?
  • $('#cal').fullCalendar({ defaultView: "month", header:{ left: 'prev,next today', center: 'title', right: 'month' },可编辑:false,可选择:true,droppable:true,事件:'inc/json.php',

标签: mysql json events fullcalendar


【解决方案1】:

当我使用您的“开始”值尝试以下示例代码时:

<html>
<head>
<script type="text/javascript">
var today=new Date('2010-11-24T07:30:00+01:00');
alert(today);
</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>

我收到警报的“无效日期”。尝试通过date object 的有效格式格式化您的开始和结束日期。 FullCalendar 在后台使用 JS 日期格式。

【讨论】:

  • 所以我的日期现在是 iso 8861 有效...但是还有另一个小问题我可以在请求完整时间戳上方发送?
  • @Timberwolf - 你是什么意思?高于要求?作为标题的一部分?
  • 不,问题是:在请求之上 :) 但我还有别的东西... array(1) { [0]=> array(5) { ["id"]=> string(2) "10" ["title"]=> string(10) "testevent1" ["start"]=> string(25) "2010-11-24T08:30:00+01:00" ["end "]=> string(25) "2010-11-24T22:00:00+01:00" ["allDay"]=> bool(false) } } [{"id":"10","title": "testevent1","start":"2010-11-24T08:30:00+01:00","end":"2010-11-24T22:00:00+01:00","allDay":false} ]
  • 这个数组有什么问题?我用这样的php函数日期转换日期(date('c',$timestamp))......我在文档中发现这种格式是正确的......我不明白跨度>
  • @Timberwolf - 尝试在一些测试 JS 中用该字符串制作日期。确保它有效。找到一种有效的格式。
【解决方案2】:

初始化时设置 allDaySlot: false 参数:

                    editable: true,
                    theme: true,
                    contentHeight:600,
                    minTime: 7,
                    maxTime: 18,
                    allDaySlot: false,

【讨论】:

    猜你喜欢
    • 2011-01-22
    • 2011-01-27
    • 2016-08-27
    • 2015-03-25
    • 2013-03-26
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 2011-10-02
    相关资源
    最近更新 更多