In my javascript code i have the following:
function foo(param1) {
setInterval( bar(param1), 3000 );
}
function bar(msg) {
alert(msg);
}
function set() {
foo('hello');
}
And on page load i call set()
, it gives the alert message only once. Why it does not work as i would expect.? I think the problem is with the parameter that i am passing the foo()
function, but what it is exactly, i am not able to figure out.
If the problem is with the parameter, what can be an alternate way to achieve the desired result.?
Thanks.