Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:47:14+00:00 2026-06-07T22:47:14+00:00

Assume that I have some files : server.php, client.php and one table : user[id,

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:47:16+00:00Added an answer on June 7, 2026 at 10:47 pm

    Remember the ID that has been given to your timer:

    var timer = setInterval( ... );
    

    and then cancel it when conditions are met:

    clearInterval(timer);
    

    The timer variable will need to be in “scope” – the simplest solution is to put all of your code inside the document.ready handler.

    FWIW, it’s actually better to use setTimeout instead of setInterval, and then re-start the timer each time around.

    setInterval will cause problems if your server goes unresponsive because it’ll dutifully keep queueing callbacks every 10 seconds. Once the server responds it’ll suddenly try to run all those callbacks straight away.

    Using setTimeout instead will ensure that no new check gets queued until the previous one has actually completed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I have 2 .php files : index.php and ajax.php This is index.php:
Assume some domain and view objects (that have no common base class) public class
Assume that i have created a client TCP Socket in Activity A. I want
Assume that I have login to system using PHP + MySQL, then, after I
I have some MySQL database server information that needs to be shared between a
Here's my situation: We have an outside provider that will be pushing XML files
I have an SSIS package that transfers some tables to CSV files on a
I have a network with one server that is connected to the internet and
I have a web application that loads some 50 tables from SQL Server into
For some reason I have always assumed that most of the time a variable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.