Do you know what exactly is AJAX?
It looks like you will be using a library for this, so take a read here: http://api.jquery.com/jquery.ajax/
If you are not planning to use jQuery, you could check this XMLHttpRequest project that is cross-browser: https://github.com/ilinsky/xmlhttprequest
Make use of AJAX periodically using a setInterval of 5 seconds where you would make a call to a PHP file you have in your server that would run the code you specified.
Take the following example:
index.html
setInterval(function() {
$.get("file.php", function (data) {
console.log('Good to go, data was loaded');
console.log(data);
});
}, 5000);
file.php
<?php
$result = mysqli_query($con,"SELECT * FROM jqcalendar ORDER BY id DESC LIMIT 0, 1");
while($row = mysqli_fetch_array($result)){
echo "a new event was added";
}
?>