I am doing long pooling using php, (which work fine) and assigning it's output JSON to fullcalender event source.
My js code
var source = new EventSource(WEBROOT+'model/applongpooling.php?start=1476037800&end=1476642600');
source.addEventListener('message', function(e) {
console.log(e.data);
$('#calendar').fullCalendar( 'removeEvents');
$('#calendar').fullCalendar('addEventSource',e.data);// here i am getting error
}, false);
My php pooling code.
<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
function SetAppointment(){
//my logic which is working fine and giving me correct result
echo 'data: ' . json_encode($res) . "\n\n";//code to get output
echo PHP_EOL;
ob_flush();
flush();
}
do {
SetAppointment();
sleep(15);
// If we didn't use a while loop, the browser would essentially do polling
// every ~3seconds. Using the while, we keep the connection open and only make
// one request.
} while(true);
?>
In console i am getting correct output.
I am getting Error,
In another js i have also assign event source to fullcalender,
eventSources: [
{
url:'model/appointments.php',
editable: true,
}
]
so my question where am i wrong, any suggestions? why am i getting such error?