mr-crocs-adventures/js/FileLoader.js
2020-01-25 13:11:25 +01:00

28 lines
566 B
JavaScript

export default class FileLoader
{
constructor(filename)
{
this.filename = filename;
this.content = '';
this.loadContent();
}
getContent()
{
return this.content;
}
loadContent()
{
let request = new XMLHttpRequest();
request.onreadystatechange = () => {
if (request.status === 200 && request.readyState === 4) {
this.content = request.responseText;
}
};
request.open('GET', this.filename, false);
request.send();
}
}