javascript - Display JSON feed on FullCalendar -
javascript - Display JSON feed on FullCalendar -
i have webpage display events on fullcalendar. have json feed located on server (restful api), , fetching this:
function getdata(selector,callback) { homecoming $.ajax({ url:"myurl/logs?" + selector, jsonp: "callback", datatype: "jsonp", success: callback }) } the selector filtering results. have utilize .done selector each time have utilize (because asynchronous behavior of ajax).
getdata().done(function(result){ // function here } the results have json format this:
[{"starttime":"2014-10-08t11:57:10.968z","endtime":"2014-10-08t11:57:15.169z"}] the fullcalendar accepts "start" , "end" identifiers. have have fullcalendar take json feed?
simply utilize events (as function)
$('#calendar').fullcalendar({ events: function(start, end, timezone, callback) { getdata().done(function(results){ var events = $.map(results, function(result) { homecoming { title: '', start: result.starttime, end: result.endtime }; }); callback(events); }); } }); javascript jquery json
Comments
Post a Comment