Stop setInterval call in JavaScript
Posted By: cnu
I am using setInterval(fname, 10000);
to call a function every 10 seconds in JavaScript. Is it possible to stop calling it on some event?
I want the user to be able to stop the repeated refresh of data.
Solution
setInterval()
returns an interval ID, which you can pass to clearInterval()
:
var refreshIntervalId = setInterval(fname, 10000);
/* later */
clearInterval(refreshIntervalId);
See the docs for setInterval()
and clearInterval()
.
Answered By: John Millikin
Related Articles
- Assign category or integer to row if value within an…
- How to create a column with a count of rows between…
- How to solve Internal Server Error in Next.Js?
- How do you match strings in custom Instruments…
- How do I convert datetime.timedelta to minutes,…
- Examples of GoF Design Patterns in Java's core libraries
- How to obtain the start time and end time of a day?
- Running a cron every 30 seconds
- Start redis-server with config file
- Backbone.js - relationship between a View and Model?
- How to get vaadin-grid to fill the page
- VueJS with normal JavaScript
- The simplest possible JavaScript countdown timer?
- Backbone.js Timer - useless setInterval call
- MS Access SQL query - Count records until value is met
- Reduce array according to grouping condition in reactjs
- Efficient Algorithm for Bit Reversal (from…
- node.js TypeError: path must be absolute or specify…
- NEXTJS, React, socketio, Rasberry Pi, DS18B20 - How…
- Javascript and SVG - move element with offset
- I need to extract working hour breaks out of a Time…
- How to multiply values using SQL
- What does an exclamation mark mean in the Swift language?
- How to filter array when object key value is in array
- Why is beforeDestroyed function not working?
- Multiple Text Field Repeater with VueJS Vee Validate
- showing record text with red color when click stop button
- How can I append a query parameter to an existing URL?
- Beautiful way to remove GET-variables with PHP?
- How to create a game over screen for a basic HTML/JS game?
- What are the new features in C++17?
- python 3.2 UnicodeEncodeError: 'charmap' codec can't…
- how to determine which bar was clicked on a chart js
- Aurelia, Electron: Possible EventEmitter memory leak…
- Need help writing a function to implement a .filter…
- Backbone.js Routers confusion (pushState: true,…
- How to access individual arguments of args passed to…
- Reactjs custom hook won't fire using an if/else in…
- How to store data within a Google Chrome Extension?
- After a little scroll, the sticky navbar just is not…
- jQuery Mobile: document ready vs. page events
- Property of Polymer object not triggering bindings…
- clearInterval() not working
- How to set timer in android?
- Using Vue to count up by seconds
- what is the Ember implementation of setInterval and…
- How to unsubscribe from setinterval only when input updated
- Rails wrong number of arguments error when…
- Vuex getter not updating value after an array update
- Vue.js Time Counter
- How to make the script wait/sleep in a simple way in unity
- What's the difference between Instant and LocalDateTime?
- How to stop a command on only one server discord.py?
- Best way to combine two or more byte arrays in C#
- Reset setInterval() from object
- how to get updated value of react useState hook from…
- Backbone.js Model, adding setInterval correctly
- How do I return the response from an asynchronous call?
- Changing the interval of SetInterval while it's running
- clearInterval is not clearing the interval
- How to iterate through property names of Javascript object?
- labeling rows in dataframe, based on dynamic conditions
- If Count is over _ amount, and FileName does NOT contain _
- Labels placed incorrectly
- How to find index of an object by key and value in…
- Timeout a command in bash without unnecessary delay
- Dead simple example of using Multiprocessing Queue,…
- vuejs start a timer for every record
- Create a simple 10 second countdown
- Syntax error near unexpected token 'fi'
- Sort table rows In Bootstrap
- How can we return data's from firebase queries with…
- Add flag -I before multiple input in snakemake
- Idle timer within Vue Component
- OpenIddict Roles/Policy returns 403 Forbidden
- How to reset the setInterval() in Js?
- Map key of object with array of object value
- Improve INSERT-per-second performance of SQLite
- Dynamically update values of a chartjs chart
- For-each over an array in JavaScript
- Replace the UUIDs with Strings
- EmberJS, polling, update route's model, re-render component
- How can I make a timer slower and slower until it stops?
- How can I print variable and string on same line in Python?
- Model change events in nested collections not firing…
- How to perform a conditional groupby calculation in…
- express force refresh client webpage
- Execute jQuery function after another function completes
- How to do a timer in Angular 5
- Waiting for other function to end in constructor function
- Hive/SQL Error when converting milliseconds to DDDD:HH:mm:ss
- Stop setInterval
- How do I clear this setInterval inside a function?
- Reference to Object is lost somehow
- What does this symbol mean in JavaScript?
- How to use setInterval and clearInterval?
- AngularJS : ng-click not working
- How to convert java.util.Date to java.sql.Date?
- How can I offset a 5 minute countdown interval timer…
- any help or idea on how to implement the timer functionality
Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.