Moved server code to utils

This commit is contained in:
Ajay Ramachandran
2020-02-01 16:41:08 -05:00
parent 5ebdfd8466
commit 4a491f1ebf
3 changed files with 83 additions and 102 deletions

View File

@@ -1,3 +1,4 @@
import * as CompileConfig from "../config.json";
import SB from "./SB";
class Utils {
@@ -268,6 +269,25 @@ class Utils {
return errorMessage;
}
static sendRequestToServer(type, address, callback) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.open(type, CompileConfig.serverAddress + address, true);
if (callback != undefined) {
xmlhttp.onreadystatechange = function () {
callback(xmlhttp, false);
};
xmlhttp.onerror = function(ev) {
callback(xmlhttp, true);
};
}
//submit this request
xmlhttp.send();
}
/**
* Is this Firefox (web-extensions)
*/