export default class Http{
static url:string = "http://127.0.0.1:8080/";
static post(method:String,data:Object,success?:Function){
let url=this.url+method;
let xhr = new XMLHttpRequest();
if(data){
let param = "?";
for(let i in data){
param += i+'='+data[i]+'&'
}
param = param.substring(0,param.length-1);
url+=param;
}
xhr.open("post", url, true);
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200){
success&&success(JSON.parse(xhr.response));
}
}
}
}