json callback now required. cross domain compatibility

This commit is contained in:
buttle 2017-03-26 23:55:48 +02:00
parent b6b986da72
commit be58812bac
2 changed files with 10 additions and 4 deletions

View file

@ -30,8 +30,14 @@ function buildFullcalendarArray($vevent, $calendar_params){
return $e;
}
///feed?start=2013-12-01&end=2014-01-12&_=1386054751381
$app->get('/feed', function ($request, $response, $args) {
///feed?start=2013-12-01&end=2014-01-12&_=138605475138
///feed?callback=?
$app->get('/feed', function ($request, $response, $args) {
$callback = $request->getParam('callback');
if (!$callback){
return null;
}
$calendarStart = strtotime($request->getParam('start'));
$calendarEnd = strtotime($request->getParam('end'));
if (!($calendarStart and $calendarEnd)){
@ -98,7 +104,7 @@ $app->get('/feed', function ($request, $response, $args) {
}
}
}
return json_encode($result);
return "$callback(" . json_encode($result) . ");";
});
$app->get('/', function ($request, $response, $args) {

View file

@ -21,7 +21,7 @@
$(document).ready(function() {
$('#calendar').fullCalendar({
// put your options and callbacks here
events: 'http://0.0.0.0:8080/feed',
events: 'http://0.0.0.0:8080/feed?callback=?',
firstDay: 1,
timeFormat: 'H:mm',
defaultView: 'listMonth',