this
当我进入一个函数时,我怎样才能保持它的值,我失去了以前的值this
例如,在这种情况下,我如何才能访问testFunction
.
admin = function()
{
this.testFunction = function()
{
alert('hello');
}
this.test2Function = function()
{
$.ajax({
url:'',
success: function()
{
this.testFunction();
// here I got an error undefined
}
});
}
}
我试图将 this 的值保留在这样的 self var 上
this.self = this;
但不工作