I am trying to access a method from my "class" from a method called asynchronously by the code.
Here is my reduced class:
function FileProcessor(file, callback) {
this.file = file;
this.callback = callback;
}
FileProcessor.prototype.readerOnload = function(e) {
this.callback(e.target.result);
};
FileProcessor.prototype.process = function() {
var reader = new FileReader();
reader.onload = this.readerOnload;
if (this.file.type == 'text/xml') {
reader.readAsText(this.file);
}
};
My cal to this.callback works from the constructor FileProcess, works from process(), but doesn't work from readerOnload. I get:
Uncaught TypeError: undefined is not a function
Any idea what I am doing wrong?
Thanks