setinterval

JavaScript multiple intervals and clearInterval

 ̄綄美尐妖づ 提交于 2019-12-24 03:17:20
问题 I have a small program, when you click on an "entry", the editing mode is opened, and the entry is to edit locked for others. There is every 10 seconds sends an ajax request to update the timestamp in the table. $(".entry-edit").click(function() { // code loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000); // code }); Then I have a cancel button to updating the timestamp in the table to 0 and to clear the interval. $(".entry-cancel").click(function() { // code

javascript setInterval not working for object

吃可爱长大的小学妹 提交于 2019-12-24 00:54:53
问题 SO, I'm trying to create a javascript object, and use the setInterval method. This doesn't seem to be working. If I remove the quotes, then the method runs once. Any ideas why? Also, I'm using Jquery. <script> $(function(){ var kP = new Kompost(); setInterval('kP.play()', kP.interval); }); var Kompost = function() { this.interval = 5000; var kompost = this; this.play = function() { alert("hello"); } } </script> 回答1: Call it like this: $(function(){ var kP = new Kompost(); setInterval(kP.play,

JQuery & Timer :: Updating the text of a hyperlink from a webservice

霸气de小男生 提交于 2019-12-23 16:07:15
问题 What I'm to figure out how to do is execute a webservice on a remote server to determine how many messages there are available to read and populate the text of a hyperlink with the message count. The trick is I'd like this to be fired from a timer (every 5 mins for example). Here's what I've been messing with $.ajax( {type:'Get',url:'http://foobar.com/ws',success:function(messageCount) { $('a.message').text(messageCount + ' Messages'); } }) but admittedly, am utterly clueless when it comes to

JS clearInterval or window.clearInterval?

让人想犯罪 __ 提交于 2019-12-23 15:29:05
问题 Javascript has setInterval and clearInterval functions for handling asynchronous function calls. Is there a difference between clearInterval(handle) and window.clearInterval(handle) ? I've seen it being used both ways. 回答1: In a browser, all global functions are implicitly properties of the window object. So clearInterval() and window.clearInterval() are the exact same thing. There is no difference between them unless you define a local function called clearInterval() , in which case window

Setinterval with exponential time decrease

早过忘川 提交于 2019-12-23 10:16:15
问题 I've got a mousedown event with a setinterval. I want the time of intervals to be variable. So the first one is 500, the second one 500/2 = 250, etc. Any tips? $plus.mousedown(function(e) { increment(20) timeout = setInterval(function(){ increment(20) }, 500); }); $(document).mouseup(function(){ clearInterval(timeout); return false; }); Cheers! EDIT: sorry for the ambiguity. I want the time of interval to change during the mousedown. So while the mousedown is being performed the intervaltime

Is it safe to pass setInterval or setTimeout a fractional delay?

删除回忆录丶 提交于 2019-12-23 09:23:29
问题 I know that the difference would currently be negligible due to inaccurate browser timers, but for the sake of knowledge if nothing else: is there any browser that supports setInterval and setTimeout, but requires that they be passed an integer value as a delay? Or, rephrased with examples, is this: setInterval(animate,50/3); as cross-browser compatible as this? setInterval(animate,17); 回答1: It is perfectly safe. (As RobG points out, I haven't provide a reference to the DOM/JS bridge rules

restarting a setInterval

我怕爱的太早我们不能终老 提交于 2019-12-23 08:57:26
问题 So I have a timer rotates a set of images ever 5 seconds. Therefore, I am running this upon document launch. $(document).ready(function() { var intervalID=setInterval(function(){ rotate(); }, 5000); }); The Rotate function simply just rotates the images. However, I also allow the user to manually select what image they are looking at. Because of this I need to cancel the SetInterval and then start it over back at 5 seconds again What I am trying to do is cancel the interval then start it over

Persist setTimeout and setInterval across Node.js restarts

瘦欲@ 提交于 2019-12-23 07:59:04
问题 I set quite a few server-side timeouts with setTimeout and setInterval for each connected user that can last for 10-30 seconds. If the Node.js instance restarts in the middle of one of these timeouts, they are obviously all cleared on restart, which can cause some issues for these users. How would I go about persisting these timeouts, or are there any modules that already help with this? 回答1: I would store the start times and durations in Redis and restart incomplete timers when your

js setInterval - increase speed gradually

情到浓时终转凉″ 提交于 2019-12-23 05:27:46
问题 How can I make setInterval to increase speed gradually, like start from 1000 ms and than go down until 40 ms gradually in few seconds by 1 ms at a time. Any thoughts? This is my code: setTimeout(function() {bonustimer = setInterval(function() { handleTimer2(rushcount); }, 40);}, 1000); handleTimer2 = function() { if(rushcount === -1) { clearInterval(bonustimer); } else { $('.digit-wrapper').html(rushcount); rushcount--; }} 回答1: Set interval probably wouldn't be what you want here, as you just

Multiple XmlHttpRequests every x seconds

喜你入骨 提交于 2019-12-23 04:41:57
问题 i need some help on some code that i m writting.. my code fires three asychronous requests and updates some content on my page. i want these requests to be fired every X seconds.. i have seen several questions like this, how to schedule ajax calls every N seconds? regarding setTimeout or setInterval, but the issue is that i need each request to be fired every x seconds..while the only i can think of that setInterval / settimeout wouldn't count seperate time for each call, but just one time..