$(document).ready(function() {
$('a#fav').bind('click', addFav(<?php echo $showUP["uID"]; ?>));
});
was before
$(document).ready(function() {
$('a#fav').bind('click', addFav);
});
I added (<?php echo $showUP["uID"]; ?>)
because i want the user profile´s id to work with in the addFav ajax call.
So i have this at the bottom of my page and now even if i havnt clicked on the a#fav it runs it? But it doesnt run itself when i dont have the (id)
Heres addFav in case:
function addFav(id){
$.ajax({
url: "misc/favAdd.php",
data: { id: id},
success: function(){
$('a#fav')
.addClass('active')
.attr('title','[-] Remove as favorite')
.unbind('click')
.bind('click', removeFav(id))
;
jGrowlTheme('wallPop', 'mono', '[+] Favorit', 'Du har nu lagt till denna profil som favorit', 'images/addFavorit_hover2.png', 1000);
}
});
}
function removeFav(id){
$.ajax({
url: "misc/favRemove.php",
data: { id: id },
success: function(){
$('a#fav')
.removeClass('active')
.attr('title','[+] Add as favorite')
.unbind('click')
.bind('click', addFav(id))
;
jGrowlTheme('wallPop', 'mono', '[-] Favorit', 'Du har nu tagit bort denna profil som favorit', 'images/addFavorit_hover2.png', 1000);
}
});
}