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:
$(data).prependTo('#ads').effect('highlight', {}, 5000);
First data
contains the rows you want to prepend. And in the second line $(data)
should be the html items that contain that data? What if you prepend the data and give those lines a class that allows you to find those rose and give them a effect?