I want to load event calendar from Database, I got this code on line and is working perfectly.
My javascript:
$('#mycalendar').monthly({
mode: 'event',
jsonUrl: 'http://localhost/acadasuite_mobile/www/calendar.php',
dataType: 'json'
});
My PHP
$startdate = "2016-10-6";
echo '{
"monthly": [
{
"id": 2,
"name": "This is a JSON event",
"startdate": "2016-10-6",
"enddate": "",
"starttime": "12:00",
"endtime": "2:00",
"color": "#EF44EF",
"url": ""
}
]
}';
ABOVE WORK WELL. But if I change the "2016-10-6" to '.$startdate.', it will not work again
ie. "startdate": '.$startdate.',
Please, what can be the problem; Is it the the javascript does not interpret the variable $startdate or PHP?
json_encode()Never try and build a JSONString yourselfjson_encode()to format the response.