How can I keep the value of this when I go inside a function I lost the previous value of this
For example in this case how can I got the access to the testFunction.
admin = function()
{
this.testFunction = function()
{
alert('hello');
}
this.test2Function = function()
{
$.ajax({
url:'',
success: function()
{
this.testFunction();
// here I got an error undefined
}
});
}
}
I’ve tried to keep the value of this on a self var like this
this.self = this;
but not work
All local variables defined in a function, propagate (could be accessed) through WHOLE function, including all functions defined in that function.
So
var top = this;will carry it’s value through all inner functions and objects declared inside ofadmin.