I have a page in a MVC app that uses setInterval
for firing a JavaScript function, calling it by its name. There are several buttons and links that, when the user clicks them, they make ajax calls to the database. Not just that, it also clears the interval and sets another function to be run (each button and link has its own function). This is not functioning properly and I would need to find out the name of the function being run by setInterval
. The debugger gives me the ID, but that's not very useful. Can I see the function's name, for debugging purposes only?
Here is a simplified version of my code:
var Abc = Abc || {
myInterval: '',
refreshTime: 120000,
init: function () {
$("#button1").click(function () {
Abc.function1();
clearInterval(Abc.myInterval);
Abc.myInterval = setInterval(Abc.function1, Abc.refreshTime);
});
$("#button2").click(function () {
Abc.function2();
clearInterval(Abc.myInterval);
Abc.myInterval = setInterval(Abc.function2, Abc.refreshTime);
});
},
function1: function () {
$.ajax({
// Code
});
},
function2: function () {
$.ajax({
// Code
});
},
}
What I need is function1
, function2
...
Thanks!!