On a page I have songs playing in a small audio player and the song change every 1-2 minutes or when I want them to(like a radio). Every song can be voted by users this way:
<span class='up'><a href="" class="vote" id="<?php echo $mes_id; ?>" name="up"><img src="up.png" alt="Down" /></a></span><br />
For upvote button, <div class="totalvotes"></div>
for total votes and
<span class='down'><a href="" class="vote" id="<?php echo $mes_id; ?>" name="down"><img src="down.png" alt="Down" /></a></span>
for downvote button.
Everything is working well but the page obviously will refresh when I click on one of the buttons to vote.
The id="<?php echo $mes_id; ?>"
from a
element is what I need to be updated every 1-2 seconds because it gets the id of the current song playing.
For the totalvotes the solution was using:
function refresh_div() {
jQuery.ajax({
url:'totalvotes.php',
type:'POST',
success:function(totalvotes) {
jQuery(".totalvotes").html(totalvotes);
}
});
}
t = setInterval(refresh_div,1000);
It was easy because I created a div with a class and specified the class in the function. But I have no ideea how can I specify the ID of a "a" to be updated every second.