I have a refreshing function which checks fresh data in the database every 60 seconds and, if found, adds it to the list.
I want it to be highlighted for a few seconds when it brings it on auto-refresh, yet it does nothing. It either highlights all the list, or nothing!
function clock(){
$.ajax({
url: "update.php",
data: "row=" + num,
cache: false,
success: function(data){
$("#ads").prepend(data);
$(data).effect('highlight', {}, 5000);
}
});
}
setInterval(clock, 60000);
What am I doing wrong?
This selector
$(data)doesn’t make sense when you use it a second time. It creates a clone since data is not a selector, but (I’m guessing a string of HTML). You should instead only create one copy of your data, and add the effect to it:Example JSFiddle post