I have made a voting feature to my website using only PHP and Smarty. This's the HTML part of it:
<p>{$vote} <a href="vote.php?q_vote=vote_up&question_id={$qid}"><i class="icon-thumbs-up"></i></a> <a href="vote.php?q_vote=vote_down&question_id={$qid}"><i class="icon-thumbs-down"></i></a></p>
The PHP part of the code takes the vote and refreshes the same page.
I want to do the same thing using jQuery so that it won't need to refresh the page. Here is what I wrote in the HTML :
$("#q_upvote").click(function()
{
var vote = "vote_up";
var votedata = "";
votedata = "vote= " + vote;
$.ajax({
type: 'POST',
url: 'vote.php',
data: votedata,
success: function(vote_msg){
if(msg == 'ok')
{
//show the new vote
}
else
//show notification
}
}
)
</script>
I couldn't figure how to show the new vote there. Can you help me with that? Also I appreciate if I'm told that if I'm going on the right way.