Good evening, is there any function that refresh on anchor link without reloading the page? I am creating a system for liking articles, but I would like to create a way to change the link "like" to "unlike. I tried to make a location.href
but the page updates what I do not want.
<script type="text/javascript">
function add_like(id_artigo){
$.post('php/add_like.php', {artigo_id:id_artigo}, function(dados){
if(dados == 'sucesso'){
get_like(id_artigo);
}else{
return false;
}
});
}
function un_like(id_artigo, id_user){
$.post('php/un_like.php', {artigo_id:id_artigo, user_id:id_user}, function(dados){
if(dados == 'sucesso'){
get_like(id_artigo);
}else{
return false;
}
});
function get_like(id_artigo){
$.post('php/get_like.php', {artigo_id:id_artigo}, function(valor){
$('#artigo'+id_artigo+'_like').text(valor);
});
}
</script>
<?php
**$selLikes verifica se existe o like**
$selLikes = getPhotoLiked($artigo_id, $user_id);
if($selLikes['num']==0){
echo'<a class="like" onclick="javascript:add_like('.$artigo_id.');this.disabled=true" href="javascript:void(0)">like</a>';
}elseif($selLikes['num']==1){
echo'<a class="unlike" onclick="javascript:un_like('.$artigo_id.', '.$user_id.')" href="javascript:void(0)">unlike</a>';
}
?>