【发布时间】:2014-04-11 17:08:09
【问题描述】:
我的代码如下所示:
function A() {
this.AFunction = function() {
var b = new B();
b.BFunction();
}
}
function B() {
this.BFunction = function() {
// some code
$.ajax({ url: url
success: BSuccess,
// and so on
})
}
this.BSuccess = function() {
// some code
this.anotherBFunc();
}
this.anotherBFunc = function() {
// some code
}
}
a = new A();
a.AFunction();
它在调用另一个BFunc 时失败。请有人帮我理解为什么会这样吗?
【问题讨论】:
-
使用
this.BSuccess.bind(this):jsfiddle.net/fRUJn/2
标签: javascript ajax oop