Wednesday, 28 August 2013

ClearInterval undefined when button clicked

ClearInterval undefined when button clicked

Suppose I have a few buttons and when they are clicked they trigger
certain setInterval, but when I clicked on different button the previous
setInterval doesn't clear or it say it is undefined.
example:
$("#button1").click(function () {
var url = "xxx";
var min = "yyy";
getGraphCredentials3(min,url);
var onehour = setInterval(function () {
getGraphCredentials3(min,url);
}, 5000);
clearInterval(twohour);
});
$("#button2").click(function () {
var url = "zzz";
var min = "uuu";
getGraphCredentials3(min,url);
var twohour = setInterval(function () {
getGraphCredentials3(min,url);
}, 5000);
clearInterval(onehour);
});
can anyone help please?
much appreciated

No comments:

Post a Comment