Assume that I have some files : server.php, client.php and one table : user[id, name, status]
server.php will handle somethings like : update user status, etc...
In client.php I have an ajax call to server.php for checking if the status is activated (in every 10 seconds):
$(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");
}
});
}
How could it be done?
Thanks for your time!