var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
};
xhr.open(‘post’, gDatagridUrl, true);
xhr.setRequestHeader(“Authorization”, sessionStorage.getItem(“token”));
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.setRequestHeader(“Accept”, “application/json”);
// xhr.onload = function () {
// if (this.status == 200) {
// var res = this.response;
// console.log(res)
// }
// };
xhr.send();
转载请注明:XAMPP中文组官网 » 原生JS发请求