我有一个“添加为好友”按钮,我希望它永久更改为“待处理请求”,直到我单击它时确认请求。当我单击该按钮时,是的,它会更改为“待处理请求”,但是每当我刷新页面时,它都会恢复为“添加为好友”。关于我应该如何做的任何帮助?
PHP部分
<div class="member" data-user="<?php echo $member['xmpp_user']; ?>" data-uid="<?php echo $member['uid']; ?>">
<img src="https://s3.amazonaws.com/wheewhew/user/<?php echo $member['uid']; ?>/photos/<?php echo $member['profile_pic']; ?>" />
<div class="member_name"><?php echo $member['firstname']." ".$member['lastname']; ?></div>
<div id="addbutton"><button type="submit" class="add" id="<?php echo $member['uid']; ?>"> Add as Buddy </button></div>
</div>
JS部分
function addBuddy(){
var xmpp_user = $(this).parent().parent().attr('data-user')+'@example.com/default';
var to_uid = $(this).parent().parent().attr('data-uid');
$.ajax({
type: "POST",
url: "./ajax/addBuddy",
data: "from_uid="+uid+"&to_uid="+to_uid,
success: function(data) {
var ret = eval('('+data+')');
if(ret.status == 'success'){
connection.send($pres({to:xmpp_user,type:'subscribe'}).tree());
}
else if(ret.status == 'requested'){
document.getElementById(to_uid).innerHTML="Pending Request";
}
}
});
}