setinterval

JS setInterval() only runs once when animating opacity

孤人 提交于 2019-12-11 20:29:13
问题 I've searched and seen that most people with this problem are passing a function call rather than function name ie: setInterval(myFunc(),100) instead of setInterval(myFunc,100) But I'm not, and it still won't work... I also saw a lot of people saying you need to parseFloat on the opacity to get it to work, I've tried that and it still yields the same result... The function runSubMenu1() appears to run just one time regardless of whether i include the if(i.style.opacity==1) clause or not Not

How can I stop a setInterval to run after executing a AJAX request that replaces that setInterval in the DOM with another setInterval?

五迷三道 提交于 2019-12-11 20:19:46
问题 I am using jQuery and I have some trouble on stopping to work the setInterval when performing a AJAX request that returns the same code containing the same setInterval . That is: Given I have the following code: <div id="test_css_id"> <a id="link_css_id" href="test_url.html">LINK</a> <script type="text/javascript"> $('#link_css_id').click(function(event) { event.preventDefault(); $.ajax({ url: $(this).attr('href'), type: 'PUT', success: function(data) { $('#test_css_id').replaceWith(data); //

make ajax call to run multiple times with setInterval

*爱你&永不变心* 提交于 2019-12-11 20:15:17
问题 I have an vb.net aspx page that loads a modal div on document.ready. then I have a function that basically does an ajax call to an aspx page that returns date/time. The ajax call then update a div in the modal div layer with the date and time All the above works when the page initially loads. BUT I want it to do that function every 5 seconds or so - but it only does it once. so what I would like in summary is... - page loads - document.ready shows modal div (this works) - then setInterval to

Print timestamp in a file not changing timestamp value

こ雲淡風輕ζ 提交于 2019-12-11 18:32:00
问题 I am trying to print the current timestamp in a file using Timers in Nodejs. If I'm using setInterval , I am able to print the current timestamp in the output file, but the the value of it never changes... (it takes the first value of timestamp and then it just prints it every 1000ms....) This was the code: export class App { private getData() { return Date.now(); } private async printToFile(path: string, data: number) { try { fs.writeFile(path, data + '\n', { 'flag': 'a' }, function (err) {

SetInterval only runs once

拜拜、爱过 提交于 2019-12-11 18:15:53
问题 This is my JavaScript code: <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> function mytest() { var jqxhr = $.get("Home/GetMonitorData", function (data) { $("#cpu").text(data.cpu); $("#dspace").text(data.dspace); $("#cspace").text(data.cspace); $("#pf").text(data.pf); $("#totphysical").text(data.totphysical); $("#freephysical").text(data.freephysical); $("#tcp").text(data.tcp); $("#req").text(data.req); }, "json"); } $(document).ready(function (

Change ticker of tradingview widget with an interval

匆匆过客 提交于 2019-12-11 17:46:23
问题 It's probably really easy but I just can't figure out how to change the ticker symbol in the Tradingview widget. I want the chart to change to the tickers in a array i got. The chart needs to change every 30 seconds with a new ticker and do that forever. This is what I got so far: <div class="tradingview-widget-container"> <div id="tradingview_5889e"></div> <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NYSE-RIG/" rel="noopener" target="_blank"><span

loop with set interval inside

佐手、 提交于 2019-12-11 14:25:51
问题 I need to write a text one by one letter, with pausing 3 sec. between. I tried this but doesn't work. After 3 sec. entire text is written at once. function thanks() { $("#writer").text(""); var txt = "Thanks for visiting !"; for ( var i = 0; i < 22; i++) { setInterval(function(){ var type = txt.substring(0, i); $("#writer").text(type); }, 3000); }; }; 回答1: You're queuing up 22 calls at once, all happening 3 seconds later. Just create your interval once, outputting new text on each call. Stop

Javascript: Force new loop iteration in setInterval

眉间皱痕 提交于 2019-12-11 14:09:38
问题 I have a setInterval loop. It's set to 3500 milliseconds, like so:- var loop = setInterval(function() { /*stuff*/ }, 3500); At one point in 'stuff' if a certain situation occurs, I want to force a new iteration of the loop and NOT WAIT for the 3500 milliseconds. How is that possible? Is it continue or do I just need to frame the process differently? 回答1: You could try writing an anonymous self-calling function using setTimeout instead of setInterval : var i = 0; (function() { // stuff i++; if

JS : Using a setTimeout inside a setInterval, the setTimeout has no effect

僤鯓⒐⒋嵵緔 提交于 2019-12-11 13:19:12
问题 I'm trying to make random images move upwards then return to their original position. <script> var looper = setInterval(animateAll, 2000, myArray); function animateAll(myArray) { // Gets a random image ID var randomId = myArray[Math.floor(Math.random()*myArray.length)]; // Make that random icon bounce bounce(randomId) ; } function bounce(randomId) { var icon = document.getElementById(randomId) var top = icon.offsetTop; setTimeout ( icon.style.top = top-20 + "px", 500) ; setTimeout ( icon

prevent javascript setInterval function stacking up

不羁岁月 提交于 2019-12-11 12:48:48
问题 I have a function that runs on a click event that uses javascript's setIterval for some of my animations (i'm doing a game) so the problem is that if a user clicks while the animation is still displaying (setInterval is still executing) the setInterval is stacking up in the event stack or that is what I found out thus either crushing my game or running twice as fast (the animation). My question is is there any way to prevent event stacking? I do not want the setInterval to stack up on the