2016-09-22 75 views
-1

我的代碼是活動不插入在自舉日曆

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"} 
]} 
+0

提供鏈接到日曆文檔 – madalinivascu

+0

https://fullcalendar.io/docs/event_data/events_function/ –

回答

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); 
} 
+0

謝謝你!它的工作你幫了我很多 –