I'm new to classes in Javascript. I worked alot in C# but in JS classes are a bit different.
I want to fill a member variable in a class from a Ajax request but the value never changes. I think some scope issues?
Here is an example.
class bla {
this.test = []; // JS Error
var test2 = []; //JS Error
constructor(blubb) {
this.blubb = blubb; // Works
this.test3 = []; //Works
}
load(){
$.ajax({
type: 'POST',
url: ajaxURL,
success: function(result) {
this.test3 = result; // Doesn't work test3 is still empty
}
});
}
}