From fcbb128f47abd2864e8616ad435cf32272aa1218 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 28 Jun 2020 16:47:54 -0700 Subject: [PATCH] Add attribute "completed" to response object. --- frontends/ycdl_flask/static/js/common.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontends/ycdl_flask/static/js/common.js b/frontends/ycdl_flask/static/js/common.js index 0b32e21..d2d7275 100644 --- a/frontends/ycdl_flask/static/js/common.js +++ b/frontends/ycdl_flask/static/js/common.js @@ -6,18 +6,25 @@ common._request = function _request(method, url, callback) { var request = new XMLHttpRequest(); + var response = { + "completed": false, + }; + request.onreadystatechange = function() { if (request.readyState == 4) { if (callback != null) { - var response = { - "meta": {}, - "data": JSON.parse(request.responseText) - }; - response["meta"]["request_url"] = url; - response["meta"]["status"] = request.status; + if (request.status != 0) + { + response["completed"] = true; + response["data"] = JSON.parse(request.responseText); + } + response["meta"] = { + "request_url": url, + "status": request.status + } callback(response); } }