10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 21:24:00 +01:00
QUESTDB_website/static/scripts/getTextFromFile.js

20 lines
509 B
JavaScript
Raw Normal View History

2019-09-09 15:15:39 +02:00
async function getTextFromFileAsync(file) {
return new Promise(function (resolve, reject) {
var req = new XMLHttpRequest();
req.open("GET",file, true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {//when a good response is given do this
var text = req.responseText;
resolve(text);
} else {
reject({
status: req.status,
statusText: req.statusText
});
}
}
}
req.send();
});
}