I have some JS code as below:
var x = self.someAJAXResponseJSON; // x has some object value here.
setTimeout(function(x){
console.log("In setTimeout:", x); // But x is undefined here
}, 1000);
So I want to pass x
to the setTimeout
callback function. But I am getting x
as undefined inside the setTimeout
.
What am I doing wrong?
Any idea how to fix a similar issue using Dojo.js?
setTimeout(dojo.hitch(this, function(){
this.executeSomeFunction(x); // What should this be?
console.log("In setTimeout:", x); // But x is undefined here
}), 1000);