setinterval

setInterval with jQuery.html only updates once?

随声附和 提交于 2019-12-24 10:40:01
问题 <?php echo ' <script type="text/javascript"> $(function() { var refresh = setInterval(function() { $("#content").html("'.rand().'"); }, 3000); }); </script> <div id="content"></div> '; ?> This will update the div "content" with a random number after 3 seconds, however it only updates once. Why does it not continually generate a new number every three seconds, and how can I make it do precisely that? Thank you in advance for any assistance rendered. 回答1: Ha. PHP is run on the SERVER side. JS

Jquery setInterval on minimize

梦想与她 提交于 2019-12-24 09:08:14
问题 I have image slider where images replace each other by timeout. I use jQuery function setInterval() but there is a small problem, after minimizing browser windows this function keep "working", and where I restore browser window images replace each other with incrediable high speed, like the whole time after window was minimized setInterval() collect actions but executing them after restoring the window. How to pause setInterval() on browser minimize or keep swap images when windows is

How to rotate an image using css3 rotate and setinterval?

有些话、适合烂在心里 提交于 2019-12-24 08:25:03
问题 I want to rotate an image using css3 rotate and javascript setinterval. The image should rotate on mouseover. Anyone know how to ? 回答1: You don't even need JavaScript to do it; just put a transition for transform on the element, and apply the rotation on hover. For example: div { background-color: red; height: 100px; -webkit-transition: -webkit-transform 0.5s ease-in-out; -moz-transition: -moz-transform 0.5s ease-in-out; -o-transition: -o-transform 0.5s ease-in-out; transition: transform 0.5s

setInterval() for an analogue clock

和自甴很熟 提交于 2019-12-24 08:20:04
问题 I'm quite new to JavaScript and I have trouble working with etInterval() . I'm creating an analogue clock as an exercise. I have a function setTime() that gets and displays the time by rotating the arrows accordingly. I want to execute this function again and again. Here is my code : $(document).ready(function(){ function setTime(){ var d = new Date(); var hour = d.getHours(); var minute = d.getMinutes(); var hourRotation = hour * 30 + (minute / 2); var minuteRotation = minute * 6; $("#small"

setInterval not working for ajax call

江枫思渺然 提交于 2019-12-24 06:03:06
问题 I have a getJson call to a webservice and works fine, Now I'm trying to make the request every 10 sec. using setInterval with a callback function to fire an alert pop up. I can't make it work. Here's the code: function ajxCall(){ $.getJSON('http://api.tubeupdates.com/?method=get.status&lines=all&return=name,status,messages,status_starts&jsonp=?', function (result){ $.each(result.response.lines, function(i, item){ $('#status').append("<p>"+item.name + " - " + item.status + " <br><b>" +item

setInterval not working for ajax call

荒凉一梦 提交于 2019-12-24 06:02:33
问题 I have a getJson call to a webservice and works fine, Now I'm trying to make the request every 10 sec. using setInterval with a callback function to fire an alert pop up. I can't make it work. Here's the code: function ajxCall(){ $.getJSON('http://api.tubeupdates.com/?method=get.status&lines=all&return=name,status,messages,status_starts&jsonp=?', function (result){ $.each(result.response.lines, function(i, item){ $('#status').append("<p>"+item.name + " - " + item.status + " <br><b>" +item

How do I change scope of “this” in setInterval and setTimeout functions

余生长醉 提交于 2019-12-24 05:40:19
问题 How is it possible to use this inside of setInterval and setTimeout calls? I want to use it like : function myObj() { this.func = function(args) { setTimeout(function() { this.func(args); }, 1000); } } Some time ago I did it for .onclick event this way : this.click = function(func) { this.elem.onclick = (function(func, obj) {return function(){func.apply(obj)} })(func,this); }; but I don't know how I can do it for intervals and timeouts . 回答1: The easiest way is to just save this into a local.

Loop setInterval function

二次信任 提交于 2019-12-24 05:39:07
问题 I'm not sure why the interval isn't looping. I've followed tutorials exactly but not luck. Suggestions? $(document).ready(function(){ setInterval(function() { $('.current').removeClass('current').next().addClass('current'); }, 2000); }); Updated: http://jsfiddle.net/pa7aU/3/ 回答1: One possible ugly solution: setInterval(function() { var $current = $(".current").removeClass("current"), $next = $current.next(); if ($next.length) $next.addClass("current"); else $current.siblings(":first")

setInterval with self-executing function

帅比萌擦擦* 提交于 2019-12-24 03:22:44
问题 I want to run my function at the first time immediately (without timeout) so I do this: setInterval(function(){ alert("Boo"); }(), 1000); The function executed at first time but in next intervals, nothing happened. Why? 回答1: The better question is, what are you actually trying to achieve ? You don't return anything from the self-invoking function, so it will return the undefined value implicitly, which is passed over to setTimeout . After the initial call, the line would look like setInterval

How to workaround a nodejs stable bug with setInterval/setTimeout when changing system time

泪湿孤枕 提交于 2019-12-24 03:18:25
问题 In the current stable version of node.js v0.10.33 there is a bug where setTimeout/setInterval does not fire anymore when setting the system time to the past. Run this code to see what I mean: var i = 0; var handle = setInterval(function() { console.log(++i); }, 1000); Then while it's running change the time of your system to the past, does not matter if on windows or linux. The interval / timeout will not fire anymore. When chaning the time to the future, node behaves perfectly fine and keeps