Imagine I have a class with two methods / functions. One method utilizes another class's function - in this case JQuery's ajax-call. Inside this function I want to address a method of my own class.
class priceSearch {
this foobar = "null";
loadStuff() {
$.ajax({url: requestUrl})
.done(function(response){
this.processStuff(response);
console.log(foobar); // -> undefined
});
}
processStuff(stuff) {
console.log(stuff);
}
}
But this will lead to
processStuff is not defined
Apparently, because processStuff is not part of ajax.done and "this" references the ajax.done.
So, how do I address parent's class method?
Same for properties: foobar from within the Ajax call will return "undefined".