いくつかのファイルがあると仮定します: server.php、client.php および 1 つのテーブル: user[id, name, status]
server.php は次のような処理を行います: ユーザーステータスの更新など...
client.php には、ステータスがアクティブになっているかどうかを確認するための server.php への ajax 呼び出しがあります (10 秒ごと):
$(document).ready(function(){
setInterval(function(){
check_user_status(user_id)
},10000);
});
check_user_status = function (user_id) {
$.ajax({
type: "post",
data: "user_id="+user_id,
url : "server.php",
success: function(data){
// do something with the response
// I want to exit the checking operation if user is already activated
},
error: function(e){
alert("Error occurred");
}
});
}
どうすればそれができますか?
御時間ありがとうございます!