use one image loader gif within a comment voting system
I have a coments stystem that allows users to upvote and downvote.
e.g something like this alongside each comment.
<div class="voteup_*commentid*">UpVote</div>
<div class="votecount_*commentid*">25</div>
<div class="votedown_*commentid*">DownVote</div>
When the user clicks one of the vote divs i want an ajax loader spinner to replace the points whilst it's fetching the updated score.
whats the best way i c开发者_如何学运维an do this?
ideally with just one spinner on the page that is positioned in the relvant "votecount" class.
When the button is clicked, add a loading spinner, and when it is finished, remove the loading spinner.
$(.voteup, .votedown).click(function(){
$(this).append("<img src='spinner.gif' id='spinner' />");
$.ajax({
//ajax function here
success: function(){
$("#spinner").remove();
}
});
});
精彩评论