function addFav(id){
$.ajax({
url: "misc/favAdd.php",
type: "POST",
data: { mode: 'ajax', user: id},
dataType: 'json',
success: function(data, status){
if(typeof(data.error) != 'undefined') {
if(data.error != '')
alert(data.error);
} else {
$('a#fav')
.addClass('active')
.attr('title','[-] Remove as favorite')
.unbind('click')
.bind('click', function() { removeFav(id); })
;
jGrowlTheme('wallPop', 'mono', '[+] Favorit', 'Du har nu lagt till denna profil som favorit', 'images/addFavorit_hover2.png', 1000);
}
}
});
}
I have this, and i wish to alert the data.error, if it gets any error response, and that works. But now, if i dont have any data.error it doesnt run the addClass and stuff thats after }else{ ?
What have i done wrong?