1
Good afternoon,
And the following I have an area where users can follow other users need to know if with jquery when clicking below it is possible to insert the data in the table and change the button not to follow and another color if possible and how can I do jquery
Example table users
Code
<script>
$(document.body).on('click', '#follow', function(e) {
e.preventDefault(); //Evita o comportamento padrão
$.ajax({
url: "ajax/processa_seguidores.php",
type: "POST",
dataTtype: "JSON",
data: {
user_logged: <?php echo $_SESSION['user_id']; ?>, //Aqui vai o usuário que clicou
user_to_follow: <?php echo $row_foodies->id; ?>, //Aqui vai o id do usuário que gostaria de seguir
}
}).done(function(data) {
if (data.error === 0) {
$( this ).addClass( "unfollow" );
$( this ).html( "Unfollow" );
alert(data.message);
//Uma sugestão você pode usar o Toastr (http://codeseven.github.io/toastr/)
//para exibir seus retornos de forma mais elegante ao seu usuário
} else {
alert('Opa algum erro ocorreu');
}
console.log(data);
});
})
</script>
<div class="my_account user wow fadeInLeft">
<figure>
<a href="users/<?php echo $row_foodies->slug; ?>"><img style=" border-top-left-radius:10px; border-top-right-radius:10px;" src="<?php echo $row_foodies->user_foto; ?>" alt="" /></a>
</figure>
<div class="container_user" style="border-bottom-left-radius:10px; border-bottom-right-radius:10px;">
<p><?php echo utf8_encode(limita_caracteres($row_foodies->fb_nome, 13, false)); ?></p>
<div style="font-family:Arial, Helvetica, sans-serif; margin-top:-15px; font-size:13px; color:#999;"><?php echo $bar['id']; ?> Opiniões</div>
<div style="font-family:Arial, Helvetica, sans-serif; margin:0px 0px 10px 0px; font-size:13px; color:#999;">0 Seguidores</div>
<?php
if($_SESSION['FBID'] || $_SESSION['user_id']){
?>
<div id="#follow" class="seguir_user" style="margin:0px 0px 15px 0px; cursor: pointer;">Seguir</div>
<?php
}
?>
</div>
You have more information, examples of your table at the base, where you would get user identification information.. ? Yes it is possible just by advancing the question.
– Rafael Withoeft
took the information from the users table this is not the problem no and as I can click on the follow button and insert the data and change the button not to follow and change the color without updating the page
– César Sousa
What I meant is, where are you going to get the user id that he wants to follow from, where is it? It’s available on the page?
– Rafael Withoeft
yes is available on the page
– César Sousa