未插入Bootstrap日历的事件

时间:2016-09-22 10:34:09

标签: java jquery jsp twitter-bootstrap-3

我的代码是

events: function(callback) {
    $.ajax({
        url: 'schoolmanagement/jsonevents',
        dataType: "json" ,
        success: function(doc) {
            var events = [];
            $(doc).find('el').each(function() {
                events.push({
                    title: $(this).attr('title'),
                    start: new Date($(this).attr('start')),
                    end: new Date($(this).attr('end')),
                    allDay: true,
                    className: 'bgm-cyan',// will be parsed
                });
            }); 
            callback(events);
        }
    });
},

我的json回复是

{"el": [
  {"end":"2016-09-25T00:00:00","start":"2016-09-25T00:00:00","title":"Weekly Holiday"},
  {"end":"2016-10-02T00:00:00","start":"2016-10-02T00:00:00","title":"Gandhi Jayanti"},
  {"end":"2016-10-09T00:00:00","start":"2016-10-09T00:00:00","title":"Weekly Holiday"},
  {"end":"2016-09-15T00:00:00","start":"2016-09-15T00:00:00","title":"School Foundation day"}
]}

1 个答案:

答案 0 :(得分:0)

您正在返回json而不是html / xml使用以下内容:

success: function(doc) {
  var events = [];
 $.each( doc.el,function(i,v) {
    events.push({
      title: v.title,
      start: v.start,
      end: v.end,
      allDay: true,
      className: 'bgm-cyan', // will be parsed
    });
  });
  callback(events);
}