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 8017727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:55:37+00:00 2026-06-04T20:55:37+00:00

How can i active/fire/trigger the setInterval with a button? and if the button is

  • 0

How can i active/fire/trigger the setInterval with a button? and if the button is not clicked how to make it auto fire on 3 second, but if i click on the button it fire it on 0.1
second and restart evrything. please help me out guys

$('button').click(function(){
    setInterval(function(){
        updateStats("updateStats");
    }, 100);
});  

else 

setInterval(function(){
    updateStats("updateStats");
}, 3000);

Edit

Only everytime the button is clicked 100ms, if not clicked then it most do it auto on 3000ms, unless you click it ofc

Part :

function updateStats(stat)
{



    var stat = ["GAME","USERS"];

    var url = "NET.php";

   $.each(stat, function(i, key){
       $.post(url, {stats: key}, function(data) { // stats to stat


          $("#" + key).html(data);  




                    $('.s').emoticonize({
                        //delay: 800,
                        //animate: false
                    });


       });


    });


} 
  • 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-04T20:55:39+00:00Added an answer on June 4, 2026 at 8:55 pm

    This will fire after 3000 if you clicked the button it will fire after 100

    var x ;
    
    // call timer after 3000
    callTimer(3000);
    
    // call timer after 100 if cicked
    $('button').click(function(){
         clearInterval(x);
         callTimer(100);
     });  
    
    
     function callTimer(time){
       x = setInterval(function(){
            updateStats("updateStats");
            }, time);
      }
    

    UPDATE upon your request

    var x ;
    var y ;
    
    // call timer after 3000
    callTimer(3000);
    
    // call timer after 100 if cicked
    $('button').click(function(){
         y = setInterval(function(){
            updateStats("updateStats");
            clearInterval(y);
            }, 100);
        callTimer(3000);
    });  
    
     function callTimer(time){
       clearInterval(x);
       x = setInterval(function(){
            updateStats("updateStats");
          }, time);
     }
    

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

Sidebar

Related Questions

how can i make the active menu in codeIgniter, its not when hover, but
I am using subsonic 2.2 with Oracle provider. I can use active record but
User can switch active application by Alt+Tab or by clicking on their icons in
How can I query Active Directory from SQL Server 2005?
Is there some way I can find all active spies in sinon.js? I'd like
Can someone who is an active JSF (or Primefaces) user explain why by default
How can I convert this query to active record? UPDATE table_user SET email =
How can I convert the following into an active record query: SELECT reviews.style_id, AVG(col1),
How can I get the url of the active aspx page from the code
How can I open a child window and keep the parent window active. I

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.