Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 完整日历+;cakephp_Jquery_Cakephp_Fullcalendar - Fatal编程技术网

Jquery 完整日历+;cakephp

Jquery 完整日历+;cakephp,jquery,cakephp,fullcalendar,Jquery,Cakephp,Fullcalendar,我设置从CakePhp的操作中获取事件: $('#calendar').fullCalendar({ header: { left: 'title', center: '', right: 'today agendaDay,agendaWeek,month prev,next' }, defaultView: 'agen

我设置从
CakePhp
的操作中获取事件:

 $('#calendar').fullCalendar({

            header: {
                left:   'title',
                center: '',
                right:  'today agendaDay,agendaWeek,month prev,next'
            },
            defaultView: 'agendaWeek',
            firstHour: 8,
            weekMode: 'variable',
            aspectRatio: 2,
            editable: true,
                  eventSources:{
                    url:'/mycontrollers/feed',
                    type:'POST',
                    error:function(data){console.log('errore feed!');
                    }
});
MyController中的操作是:

public function feed()
    {  
        if ($this->request->is('ajax'))
        {
            $data = $tis->request->data;
            $res = array('title'=>'prova','start'=>'2014-03-19 21:00:00');
           return new CakeResponse(array('body'=>json_encode($res)));

        }

    }
当我加载页面
fullcalendar
is时,没有显示任何事件,并且在JS调试区域中,我没有看到对操作的ajax调用。 我错过了什么

[编辑]

现在它工作了(我在events中更改了eventSources)。数据事件返回到ajax,但未显示在日历中

解决方案

这是数据数组中的一个错误

$res[] = array('title'=>'prova','start'=>'2014-03-19 21:00:00');
试试这个,让我们看看

//in your controller
function feed(){
       ....
       ....
      //return json
      $this->set('events', json_encode($res));
}

//view
<script>
   var events = <?php echo $events; ?>
   var eventList = jQuery.parseJSON( events );


$('#calendar').fullCalendar({
    defaultDate: '2014-01-12',
    editable: true,
    events: eventList
});
</script>
//在控制器中
函数提要(){
....
....
//返回json
$this->set('events',json_encode($res));
}
//看法
var事件=
var eventList=jQuery.parseJSON(事件);
$(“#日历”).fullCalendar({
默认日期:“2014-01-12”,
是的,
事件:事件列表
});

问题似乎出在eventSources中:应该是events,而不是EventSource。我正在阅读fullCalendar的文档