119
rated 0 times
[
121]
[
2]
/ answers: 1 / hits: 19436
/ 9 Years ago, fri, april 24, 2015, 12:00:00
I have this function:
function doStuff(range, file) {
var fr = new FileReader();
var hash = '';
fr.onload = function (e) {
var out = stuff happens here;
hash = asmCrypto.SHA256.hex(out);
return hash;
};
fr.readAsArrayBuffer(file);
return hash;
}
Right now, the function completes before the onload event is finished, so doStuff always returns . I think a callback is what I need, but I'm new to javascript, and I can't wrap my mind around how to implement it in this case.
More From » callback