const getJson = function(url,type,data){
const xmlHttp = new xmlHttpRequset();
xmlHttp.open(type,url);
if(type == "GET"){
xmlHttp.send()
}else{
xmlHttp.setRequestHeader("Conten-Type","application/json")
xmlHttp.send(JSON.stringify(data));
}
xmlHttp.responseType = "json";
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState !=4) return;
if(xmlHttp.status == 200){
seolve(xmlHttp.response)
}else{
reject(new Error(xmlHttp.statusText))
}
}
return prommise;
}
//調(diào)用
document.querySelector(".query").onclick = (){
getJson("http://127.0.0xxx/get_list",'GET')
.then(function(res){
console.log(res)
},function(error){
console.log(error)
})
}