I'm wondering whether there is a simple way to stop the same data being printed over and over.
My notification system searches from the last notification_id for a new one, if successful it puts that new data into a dic, but because the page isn't refreshed, when it then searches again it searches the same id and posts the same new id and this keeps repeating. So I thought, would it be ok to add a random number or time at the end of the url to stop this repeating so I only get new results shown in my div the once.
<script type="text/javascript">
setInterval(function(){
var notification_id="<?php echo $notification_id['notification_id'] ;?>"
$.ajax({
type: "GET",
url: "viewajax.php?notification_id="+notification_id,
dataType:"json",
cache: false,
success: function(response){
if(response.num){
$("#notif_actual_text-"+notification_id).prepend('<div id="notif_actual_text-'+response['notification_id']+'" class="notif_actual_text"><a href="'+response['notification_id']+'">'+response['notification_content']+' </a><br />'+response['notification_time']+'</div></nr>');
$("#mes").html(''+ response.num + '');
}
}
});
},20000);
</script>