Great response, Mike. In the plugin that the OP mentioned, it uses neither, but uses a recursive function instead. To cancel the recursive function, one would need to use a variable, and check it's value with each recursive function call. I replied to this post earlier, but it didn't seem to post?
Renato On Nov 12, 5:39 pm, Michael Geary <m...@mg.to> wrote: > Now MorningZ, that is possibly the worst comparison of setInterval() and > setTimeout() that I've ever seen! > > (Please take that as a little good-natured ribbing among friends, OK?) > > Both setInterval() and setTimeout() are cancelable, using clearInterval() > and clearTimeout() respectively. > > The difference between setInterval() and setTimeout() is that setTimeout() > calls the callback function only once (or not at all if you cancel it > first). setInterval() calls the callback function repeatedly until you > cancel it. > > https://developer.mozilla.org/en/DOM/window.setIntervalhttps://developer.mozilla.org/en/DOM/window.setTimeout > > You're certainly right on the essential point: a bit of simple code using > setInterval() or setTimeout() may well be all that Mark needs. Mark, you may > want to look at the source code of that plugin and see where it calls one of > these two functions. That will give you some idea of how you could use them > in your own code. > > Also beware: "this" inside a setInterval() or setTimeout() callback is not > what you expect! > > -Mike > > On Thu, Nov 12, 2009 at 5:28 PM, MorningZ <morni...@gmail.com> wrote: > > Not really requiring jQuery, just read up on JavaScript's setInterval, > > which is like setTimeout except you can cancel it > > > On Nov 12, 7:39 pm, Mark <mark...@gmail.com> wrote: > > > Hi, > > > > i tried this jquery countdown plugin: > >http://davidwalsh.name/jquery-countdown-pluginandit works neat.. but > > > not for my interest. > > > What i try to do is have this: > > > > Have a simple countdown that counts down from 5 to 0 then changes the > > > text to "Uploading..." > > > The plugin mentioned can do that but i also want to be able to > > > "cancel" the countdown which it can't do. > > > Can anyone point me to a plugin that does have that functionality? or > > > how i make that in this plugin.. > > > > So what i want to be able to do: > > > > 5 > > > 4 > > > 3 > > > 2 > > > 1 > > > 0 > > > Uploading... > > > > Or when cancel is pressed > > > > 5 > > > 4 > > > 3 > > > 2 > > > CANCEL > > > > Just like that. > > > > I hope anyone can help me with this. > > > > Thanx, > > > Mark. > >