function ajaxPromise(method,url,data) { return new Promise((resolve, reject) => { var xhr = null; var method = method || 'GET'; var data = data || null; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } xhr.open(method, url, true) xhr.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200) { resolve(JSON.parse(this.responseText), this) } else { var resJson = { code: this.status, response: this.response } reject(resJson, this) } } } if(method == 'GET'){ xhr.send() }else{ xhr.setRequestHeader(