I have some jquery that runs when a link is clicked (below). This allows data to be sent to a mysql database and then update the value of a certain <p>. However, this isn’t working. I added an alert(response) and i am getting the correct result, but the <p> doesnt change which probably means i am using the wrong selector.
JQUERY:
$('.upVote').click(function(e){
e.preventDefault();
answer_id = $(this).siblings('.record_id').attr('value');
$.post('../answerrating.php' , {answer_id: answer_id} , function(response){
$(this).prev('.ratingBox').val(response);
});
});
HTML:
<p class='ratingBox'> $answerrating[$f]</p>
<a href='#' class='upVote'>Upvote</a> <a href='#' class='downVote'>Downvote</a>
<input type='hidden' name='record_id' value='$answerid[$f]' class='record_id' />
try this.