From 1a7f8644925c3b0086e421b6b166432759d9aa79 Mon Sep 17 00:00:00 2001 From: kor Date: Sun, 12 Aug 2018 03:43:33 +1200 Subject: [PATCH] Fix inconsistent data loading. --- docs/logic/main.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/logic/main.js b/docs/logic/main.js index 35e8e1f..74feb7a 100644 --- a/docs/logic/main.js +++ b/docs/logic/main.js @@ -11,18 +11,11 @@ function Main() this.install = function() { - var client = new XMLHttpRequest(); - client.open('GET', FILELOCATION); - client.overrideMimeType("text/plain"); - client.onreadystatechange = function(req, res) - { - if (client.responseText.trim() != '') - { - client.onreadystatechange = null; - parent.setup(client.responseText); - } - } - client.send(); + var oReq = new XMLHttpRequest(); + oReq.open('GET', FILELOCATION); + oReq.overrideMimeType("text/plain"); + oReq.addEventListener("load", function() { parent.setup(this.responseText); } ); + oReq.send(); } this.setup = function(data)