【发布时间】:2013-01-13 16:42:39
【问题描述】:
这是我的 ajax 调用(几乎是标准的 jQuery,但使用的是 couchdb jquery 库,http://daleharvey.github.com/jquery.couch.js/):
var stuff = "some stuff";
$.couch.db("test_db").create({
success: enyo.bind(this, function (data) {
console.log(stuff);
})
});
stuff = "a change in stuff";
我希望 console.log 的输出是“一些东西”而不是“东西的变化”。
执行此操作的方法越多越好,因为我认为某些方法可能需要我不使用“enyo.bind”(http://enyojs.com/),但也许我可以用这些方法完成同样的事情。
【问题讨论】:
标签: jquery ajax variables scope