So I have this notification system that uses jQuery and PHP. The jQuery checks the PHP script every few seconds, and if there is a change, it is displayed. I want to know how to detect a change in the data (like from ‘1’ to ‘2’) and then responding by causing the object to animate (using this: $(this).effect(“shake”, { times:3 }, 300);). How can I do this?
jQuery
$(document).ready(function()
{
$.get('/codes/php/nf.php', function(data
{
$('#badge').badger(data);});});
setInterval(function(){
$.get('/codes/php/nf.php', function(data)
{
$('#badge').badger(data);});}, 8000);
You could detect change on your PHP script, and depending on change in data (ie whether data has changed or not), you could pass in appropriate value to your js script and process accordingly..