<script>
$(document).ready(function(){
$(".add_friend").click(function(){
f_id = this.id;
user_id = <?php echo $_SESSION['user_id']; ?>;
$.ajax({
type:"POST",
data:{"f_id":f_id,"user_id":user_id},
url:"request_send.php",
success:function(data){
$("#add").css("display","none");
$(".friend").css("display","block");
}
});
});
});
</script>
<div class="profile_btnn" id="add" style="display:block;">
<button type="submit" name="add_friend" id="<?php echo $row_add['user_id']; ?>" class="btnplus add_friend"><i class="fa fa-plus"></i> Add Friend</button>
</div>
<div class="friend" style="display:none;">
<div class="profile_btnn set_btn">
<button type="submit" name="req_sent" id="<?php echo $row_req['f_id']; ?>" class="btnplus req_sent"><i class="fa fa-plus"></i> Request Sent</button>
</div>
</div>
在此代码中。我想在ajax成功之后将div即id="add"
更改为class="friend"
。现在,当我单击add_friend
时会发生什么,它成功运行并用id="add"
更改class="friend"
。但是问题是,当我刷新页面时,它再次向我显示add friend
。那么,如何解决此问题?请帮助我。
谢谢