我有一些JS代码如下:
var x = self.someAJAXResponseJSON; // x has some object value here.
setTimeout(function(x){
console.log("In setTimeout:", x); // But x is undefined here
}, 1000);
所以我想传递x
给setTimeout
回调函数。但我x
在setTimeout
.
我究竟做错了什么?
知道如何使用 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);