I am not getting any error and also this is not working the way I want it to be. I have a jQuery upvote plugin in my project. To avoid span I am validating user input on every vote. Everything is working and I am getting the error If I try to span the voting functionality from my php file. The problem is when I try to show that message on the screen just like stack overflow.
Currently I have this but the out is not what I wanted:
<script>
var callback = function(data) {
$.ajax({
url: 'voting.php',
type: 'post',
data: { id: data.id, up: data.upvoted, down: data.downvoted, star: data.starred },
success: function(result) {
$("[data-id='" + data.id + "']").html(result);
}
});
};
$('.upvote').upvote({callback: callback});
</script>
Output where the error replaces the up and down vote :

My html which has a span tag but not sure how to use it?
if($RES['counter'] === '1'){
echo '
<td>
<div data-id='.$id.' class="upvote upvote-serverfault">
<a style="cursor:pointer;" class="upvote upvote-on" title="This idea is helpful"></a>
<span class="count">'.$counter.'</span>
<a class="downvote"></a>
<span class="votingFeedback"></span>
</div>
</td>';
}
else
if($RES['counter'] === '-1'){
echo '
<td>
<div data-id='.$id.' class="upvote upvote-serverfault">
<a style="cursor:pointer;" class="upvote upvote-down" title="This idea is helpful"></a>
<span class="count">'.$counter.'</span>
<a class="downvote downvote-on"></a>
<span class="votingFeedback"></span>
</div>
</td>';
}
$.ajax({
url: 'voting.php',
type: 'post',
data: { id: data.id, up: data.upvoted, down: data.downvoted, star: data.starred },
success: function(result) {
$("[data-id='" + data.id + "']").find("span.votingFeedback").text(result);
}
});
Using this you can show the error in the respective span element with class votingFeedback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With