JSON中的意外标记j(完整日历)

时间:2016-11-07 10:59:30

标签: php jquery json fullcalendar

最近将我的Laravel项目从我的桌面移动到托管的Web服务器,除了我的完整日历之外,一切正常,我现在收到JSON错误,这意味着没有任何内容被拉入日历。

这是错误:

Error

这是其识别错误的代码的一部分:

$('#calendar').fullCalendar({
    events: JSON.parse(json_events),
    utc: true,

数据通过php从数据库中提取,然后由此获取。

$.ajax({
url: "{{asset("../vendors/fullcalendar/process.php")}}",
    type: 'POST', // Send post data
    data: 'type=fetch',
    async: false,
    success: function(s){
      json_events = s;
    }
});

PHP位

if($type == 'fetch')
{
    $events = array();
    $query = mysqli_query($con, $fetch_renewals);
    while($fetch = mysqli_fetch_array($query,MYSQLI_ASSOC))
    {
    $e = array();
    $e['id'] = $fetch['id'];
    $e['title'] = $fetch['title'];
    $e['start'] = $fetch['startdate'];
    $e['end'] = $fetch['enddate'];


    $allday = ($fetch['allDay'] == "true") ? true : false;
    $e['allDay'] = $allday;

    array_push($events, $e);
    }


    echo json_encode($events);
}

从.CSV复制的PHP查询的输出

"id","title","info","startdate","enddate","allDay","type","type_id","updated_at","created_at","repeat_event_id","report_id","information","association_id","reminder_180","reminder_90","reminder_60","reminder_30"
18,"test","test","2016-11-10","2016-11-10","","repeatschool",143,"2016-11-02 10:59:22","2016-11-02 10:59:22",23,NULL,NULL,NULL,"Yes","Yes","Yes","Yes"
19,"test","test","2017-11-10","2017-11-10","","repeatschool",143,"2016-11-02 10:59:22","2016-11-02 10:59:22",23,NULL,NULL,NULL,"Yes","Yes","Yes","Yes"
20,"test","test","2018-11-10","2018-11-10","","repeatschool",143,"2016-11-02 10:59:22","2016-11-02 10:59:22",23,NULL,NULL,NULL,"Yes","Yes","Yes","Yes"
21,"test","test","2019-11-10","2019-11-10","","repeatschool",143,"2016-11-02 10:59:22","2016-11-02 10:59:22",23,NULL,NULL,NULL,"Yes","Yes","Yes","Yes"
22,"test","test","2020-11-10","2020-11-10","","repeatschool",143,"2016-11-02 10:59:22","2016-11-02 10:59:22",23,NULL,NULL,NULL,"Yes","Yes","Yes","Yes"
23,"Broadband Renewal Reminder","Money Saving Report","2016-11-16","2016-11-16","","reportschool",134,"2016-11-02 14:36:40","2016-11-02 14:36:40",NULL,46,NULL,NULL,"Yes","Yes","Yes","Yes"
24,"Web Filtering Renewal Reminder","Money Saving Report","2016-11-15","2016-11-15","","reportschool",134,"2016-11-02 14:36:40","2016-11-02 14:36:40",NULL,46,NULL,NULL,"Yes","Yes","Yes","Yes"
25,"Firewall Renewal Reminder","Money Saving Report","2016-11-13","2016-11-13","","reportschool",134,"2016-11-02 14:36:40","2016-11-02 14:36:40",NULL,46,NULL,NULL,"Yes","Yes","Yes","Yes"
26,"Anti-Virus Renewal Reminder","Money Saving Report","2016-11-21","2016-11-21","","reportschool",134,"2016-11-02 14:36:40","2016-11-02 14:36:40",NULL,46,NULL,NULL,"Yes","Yes","Yes","Yes"
27,"Broadband Renewal Reminder","Money Saving Report","2016-11-16","2016-11-16","","reportschool",135,"2016-11-02 15:01:42","2016-11-02 15:01:42",NULL,47,NULL,NULL,"Yes","Yes","Yes","Yes"
28,"Broadband Renewal Reminder","Money Saving Report","2016-11-11","2016-11-11","","reportschool",135,"2016-11-02 15:02:33","2016-11-02 15:02:33",NULL,51,NULL,NULL,"Yes","Yes","Yes","Yes"

我在网上有一个很好的搜索,但我已经相当失去了这一切,只是刚开始学习这门语言。

任何指针都会非常感激。

附上console.log

console.log([{"id":"18","title":"test","start":"2016-11-10T00:00:00","end":"2016-11-10T00:00:00","allDay":false},{"id":"19","title":"test","start":"2017-11-10","end":"2017-11-10","allDay":false},{"id":"20","title":"test","start":"2018-11-10","end":"2018-11-10","allDay":false},{"id":"21","title":"test","start":"2019-11-10","end":"2019-11-10","allDay":false},{"id":"22","title":"test","start":"2020-11-10","end":"2020-11-10","allDay":false},{"id":"23","title":"Broadband Renewal Reminder","start":"2016-11-16","end":"2016-11-16","allDay":false},{"id":"24","title":"Web Filtering Renewal Reminder","start":"2016-11-15","end":"2016-11-15","allDay":false},{"id":"25","title":"Firewall Renewal Reminder","start":"2016-11-13","end":"2016-11-13","allDay":false},{"id":"26","title":"Anti-Virus Renewal Reminder","start":"2016-11-21","end":"2016-11-21","allDay":false},{"id":"27","title":"Broadband Renewal Reminder","start":"2016-11-16","end":"2016-11-16","allDay":false},{"id":"28","title":"Broadband Renewal Reminder","start":"2016-11-11T06:00:00","end":"2016-11-11T06:00:00","allDay":false}])

1 个答案:

答案 0 :(得分:0)

试试这是代码<?php error_reporting(0); ob_clean(); ?> 并且不要忘记这是标题后的代码替换 示例:

<?php require_once 'header.php'?>

//here code 
 <?php error_reporting(0); ob_clean(); ?>

<body>
  //You're Contain
</body>

<?php require_once 'footer.php' ?>