diff --git a/Plan/common/src/main/resources/assets/plan/web/js/xmlhttprequests.js b/Plan/common/src/main/resources/assets/plan/web/js/xmlhttprequests.js new file mode 100644 index 000000000..9b4fcbbda --- /dev/null +++ b/Plan/common/src/main/resources/assets/plan/web/js/xmlhttprequests.js @@ -0,0 +1,30 @@ +/** + * Make an XMLHttpRequest for JSON data. + * @param address Address to request from + * @param callback function with (json, error) parameters to call after the request. + */ +function jsonRequest(address, callback) { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + if (this.readyState === 4) { + try { + if (this.status === 200) { + var json = JSON.parse(this.responseText); + callback(json, null) + } else if (this.status === 404 || this.status === 403 || this.status === 500) { + callback(null, this.status) + } + } catch (e) { + callback(null, e.message) + } + } + }; + xhttp.open("GET", address, true); + xhttp.send(); +} + +function asyncJsonRequest(address, callback) { + setTimeout(function () { + jsonRequest(address, callback) + }, 0); +} \ No newline at end of file diff --git a/Plan/common/src/main/resources/assets/plan/web/network.html b/Plan/common/src/main/resources/assets/plan/web/network.html index b34f8fdd0..dfa60db25 100644 --- a/Plan/common/src/main/resources/assets/plan/web/network.html +++ b/Plan/common/src/main/resources/assets/plan/web/network.html @@ -1261,14 +1261,12 @@ + - - - + - - - + - - + + - - +