- post请求
this.postJSON = function (url, arg, success, failure,async) {
console.log("==========jsPostJSON>>>>>>>>>>>>>>>>==========",url)
var xhr = new XMLHttpRequest;
xhr.open("POST", url,async);
xhr.setRequestHeader("content-type", "application/json"); //用POST的时候一定要有这句
xhr.onreadystatechange = function() {
handleResponse(xhr, success, failure);
}
xhr.send(JSON.stringify(arg));
}
- get请求
//async:true表示异步,false表示同步(可选,默认为true)
this.httpGet = function(url,success, failure,async)
{
console.log("==========jsGet>>>>>>>>>>>>>>>&g