By clicking on the positive frame (indicated in the figure by an arrow), the user accepts the friendship invitation.
Ineedtopasstheuserid(value15)totheupdate-friends.phppage.Theeventishostedbytheinvitations.jspage:
$(document).ready(function(){$("#aceitar").click(function(){
var id = ????????? ;
$.post('atualizar-amigos.php', {amigo:id}, function(){
$(".item").remove();
});
});
});
The user id is stored in the $ user_id PHP variable. I've tried:
var id = <?= $user_id?>;
var id = <?php echo $user_id; ?>;
var id = "<?php echo $user_id; ?>";
In the first 2 options, it gives an error. In the third, the value passed is
"<?php echo $user_id;?>"
(and not value 15)
I also created the JSON $ frind (printed on the image) and tried:
var id = frind['id'];
But it did not work either. How do I access the id value (in JSON) OR the PHP variable ($ user_id) in the Ajax post function?