-------------------------HTML code----------------------------
<body class="bdy">
<?php include "includes/head.php"; ?>
<?php
//include "includes/connection.php";
$us=$_GET['Uid']; (user id to post)
echo '<div class="container">
<button class="btn followButton follow" rel="6">Follow</button>
</div>';
include "includes/uprofile1.php";
include "includes/footer.php";
?>
<script src="style/javascript/follow.js"></script>
</body>
-------------------jquery code-----------------------
$(document).ready(function(){
$('button.followButton').on('click', function(e){
e.preventDefault();
$button = $(this);
if($button.hasClass('following')){
//$.ajax(); Do Unfollow
//this is only the button code i need help in adding the ajax call....
$button.removeClass('following');
$button.removeClass('unfollow');
$button.text('Follow');
} else {
var data=$(this).attr('Uid');
$.ajax({
url:"follow.php",
type:"post",
data:data,
});
$button.addClass('following');
$button.text('Following');
}
});
$('button.followButton').hover(function(){
$button = $(this);
if($button.hasClass('following')){
$button.addClass('unfollow');
$button.text('Unfollow');
}
}, function(){
if($button.hasClass('following')){
$button.removeClass('unfollow');
$button.text('Following');
}
});
});
please someone help me in inserting the ajax post, to post the user id to mysql .i don't understand how to make the ajax call and all.
Since you provided no errors i will guess..
$.ajax({
url:"follow.php",
type:"post",
data:data
});
Had to remove the extra comma after data:data
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.