const xhr = new XMLHttpRequest();
console.log(xhr.readyState);
xhr.onreadystatechange = () => {
console.log(xhr.readyState);
if (xhr.readyState !== 4) return;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
console.log(xhr.responseText);
}
};
// xhr.open('GET', 'text.json', true);
// xhr.send(null);
xhr.open('POST','text.json',true);
xhr.send('123')
具体报什么错?跨域还是 。404. 404文件地址错误 。跨域 就需要 解决跨域 。jsonp或者 代理