Reputation: 787
I am trying to get javascript setTimeout function working with callback, but getting "missing formal parameter" error from func function...
var pCodes = [ 'a','b','c' ];
$.each(pCodes, function(index, pCode) {
setTimeout(function() {
func(pCode, callback);
}, 2000);
});
function func(in, callback){
callback(in);
}
function callback(value) {
alert(value);
}
Upvotes: 0
Views: 133
Reputation: 18546
I dont think in
is as allowed variable name. I think its a reserved keyword
Upvotes: 2