window.addEvent('domready',function(){
new Calendar({
calContainer:'calBody',
newDate:'04/05/2018',
cEvents: []
});
})
var request = new XMLHttpRequest();
request.open('GET', 'eventFeed.php', true);
request.onload = function () {
// begin accessing JSON data here
var data = JSON.parse(this.response);
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
}
request.send();
var request = new XMLHttpRequest();
request.open('GET', 'eventFeed.php', true);
request.onload = function () {
// begin accessing JSON data here
var data = JSON.parse(this.response);
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
new Calendar({
calContainer:'calBody',
newDate:'04/05/2018',
cEvents: data
});
}
window.addEvent('domready',function(){
var request = new XMLHttpRequest();
request.open('GET', 'eventFeed.php', true);
request.onload = function () {
// begin accessing JSON data here
var data = JSON.parse(this.response);
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
new Calendar({
calContainer:'calBody',
newDate:'04/05/2018',
cEvents: data
});
}
})
window.addEvent('domready',function(){
var request = new XMLHttpRequest();
request.open('GET', 'eventFeed.php', true);
request.onload = function () {
// begin accessing JSON data here
var data = JSON.parse(this.response);
console.log('data = ', data);
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
new Calendar({
calContainer:'calBody',
newDate:'04/05/2018',
cEvents: data
});
}
})
Все равно белый лист
тогда проверяйте , что в data приходит
console.log('data = ', data);
, чтобы вы могли посмотреть, что напишет консоль. window.addEvent('domready',function(){
var request = new XMLHttpRequest();
request.open('GET', 'Demo - MooTools Events Calendar_files/data.json', true);
console.log('request = ', request);
request.responseType = 'json';
request.send(null);
request.onload = function () {
// begin accessing JSON data here
var data = this.response.data;
console.log('data = ', data);
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
console.log(new Calendar({
calContainer:'calBody',
newDate:'04/05/2018',
cEvents: data
}));
}
})
var request = new XMLHttpRequest();
request.open('GET', 'eventFeed.php', true);
console.log('request = ', request);
request.responseType = 'json';
request.send(null);
request.onload = function () {
var data = this.response.data;
for (var i = 0; i < data.length; i++) {
console.log(data[i].title + ' is a ' + data[i].start + '.');
}
if(!request.response.data) {
console.log('request.response.data is missing');
} else {
console.log('data = ', data, "\n",
new Calendar({
calContainer:'calBody',
newDate:'02/05/2009',
cEvents: data
}), Array.isArray(data));
}
}
<?php
$events[] = array('title'=>'Jimmy\'s Birthday','start'=>'2018-04-01','end'=>'2018-04-01','location'=>'');
$events[] = array('title'=>'E-Waste Recycle Day','start'=>'2018-04-12T07:00:00-06:00','end'=>'2018-04-13T15:00:00-06:00','location'=>'Recycle Center');
$events[] = array('title'=>'Breakfast','start'=>'2018-04-18T06:00:00-05:00','end'=>'2018-04-18T07:00:00-05:00','location'=>'');
$events[] = array('title'=>'Wash Car','start'=>'2018-04-18T08:00:00-05:00','end'=>'2018-04-18T09:00:00-05:00','location'=>'');
$events[] = array('title'=>'Read Up On Rocket Science','start'=>'2018-04-18T09:00:00-05:00','end'=>'2018-04-18T10:00:00-05:00','location'=>'');
$events[] = array('title'=>'Build The Projectile','start'=>'2018-04-18T13:00:00-05:00','end'=>'2018-04-18T13:30:00-05:00','location'=>'');
$events[] = array('title'=>'Launch The Missile','start'=>'2018-04-18T18:00:00-05:00','end'=>'2018-04-18T20:00:00-05:00','location'=>'');
$events[] = array('title'=>'Labor Day','start'=>'2017-09-07','end'=>'2017-09-07','location'=>'');
$events[] = array('title'=>'Subliminal Closing Party','start'=>'2017-09-30','end'=>'2017-10-01','location'=>'Pacha - Ibiza, Spain');
header('Content-type: application/json');
echo json_encode($events);
?>
<?php
$events[] = array('title'=>'Jimmy\'s Birthday','start'=>'2018-04-01','end'=>'2018-04-01','location'=>'');
$events[] = array('title'=>'E-Waste Recycle Day','start'=>'2018-04-12T07:00:00-06:00','end'=>'2018-04-13T15:00:00-06:00','location'=>'Recycle Center');
$events[] = array('title'=>'Breakfast','start'=>'2018-04-18T06:00:00-05:00','end'=>'2018-04-18T07:00:00-05:00','location'=>'');
$events[] = array('title'=>'Wash Car','start'=>'2018-04-18T08:00:00-05:00','end'=>'2018-04-18T09:00:00-05:00','location'=>'');
$events[] = array('title'=>'Read Up On Rocket Science','start'=>'2018-04-18T09:00:00-05:00','end'=>'2018-04-18T10:00:00-05:00','location'=>'');
$events[] = array('title'=>'Build The Projectile','start'=>'2018-04-18T13:00:00-05:00','end'=>'2018-04-18T13:30:00-05:00','location'=>'');
$events[] = array('title'=>'Launch The Missile','start'=>'2018-04-18T18:00:00-05:00','end'=>'2018-04-18T20:00:00-05:00','location'=>'');
$events[] = array('title'=>'Labor Day','start'=>'2017-09-07','end'=>'2017-09-07','location'=>'');
$events[] = array('title'=>'Subliminal Closing Party','start'=>'2017-09-30','end'=>'2017-10-01','location'=>'Pacha - Ibiza, Spain');
// header('Content-type: application/json');
echo '{"data":' . json_encode($events) . '}';
?>
window.addEvent('domready',function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log('responseText:' + xmlhttp.responseText);
try {
var data = xmlhttp.responseText;
} catch(err) {
console.log(err.message + " in " + xmlhttp.responseText);
return;
}
new Calendar({
calContainer:'calBody',
newDate:'04/01/2018',
cEvents: data,
})
}
};
xmlhttp.open("GET", 'eventFeed.php', true);
xmlhttp.send(null);
});