I am designing a like and dislike feature. But problem arise when i update my like as the same time it must update the dislike div
too.
this is my .js for dislike:
$('.dislike').click(function(e) {
dislike = $(this);
to_dislike= dislike.data('val');
$.ajax({
type : 'POST',
url : '<?php echo site_url('/url.php');?>',
data : 'dislikes='+to_dislike,
dataType : 'text',
success : function(data){
$("#dislike_"+to_dislike).html(data);
},
error : function(){
$("#dislike_"+to_dislike).html('Sorry');
}
});
});
Its working good. but i want to modify it in such a way that it should simultaneously update my div:
<div id='like'></div>
Here is my HTML :
<table>
<tr>
<td> <button class="like"></button></td>
<td> <button class="dislike"></button></td>
</tr>
<tr>
<td>LIKE : <div id='like'></div></td>
<td> Dislike : <div id='dislike'></div></td>
</tr>
</table>
EDIT:
Update: I have to fetch data about like and dislike at same time and then put that data in two different div's. There is a table with like
and dislike
column.On like i update my likes. But if a person dislike after liking a particular post then dislike is updated to +1 and like is updated to -1.
please help..