am creating a blogging project. i want everytime a new post is created, the user doesnt have to refresh the page to see the post, it will just append to the already existing ones. this is what am doing presently
function postTin() {
$.ajax({
type:'POST',
url: "frextra.php",
data:"ins=passPost",
success: (function (result) {
$("#post").html(result);
})
})
}
postTin(); // To output when the page loads
setInterval(postTin, (5 * 1000)); // x * 1000 to get it in seconds
what am doing here is that every 5 seconds the page goes to reload the posted data in which case it will also add the newly posted ones
what i want is this: i don't want to use a timer, i want the request to only load when there is a new post added in the database. been stuck here for two weeks. searched around and have not seen anything to help.