In the javascript below. the like_add function takes the else route. intead of taking the if route. even though it returns success. so my question is why? the data returns success but it doesnt move to the like_get function, instead it alerts(data) success.
function like_add(id){
$.post('ajax/like_add.php',{id:id},function(data){
if(data == "success"){
like_get(id);
}else{
alert(data);
}
});
}
function like_get(id){
$.post('ajax/like_get.php',{id:id},function(data){
$('#post_'+ id +'_likes').text(data);
});
}
try to trim data first , it’s probably some space or hidden characters which you can see on the alert
also alert data length so you can be sure