使用: xhr.responseText;

var xhr = new XMLHttpRequest();
xhr.open('GET', '/server', true);

xhr.responseType = 'text';
xhr.onload = function () {
  if (xhr.readyState === 4 && xhr.status === 200) {
    console.log(xhr.responseText);
  }
};

xhr.send(null);

 

注意: xhr.responseType等于空字符或"text"时, 可以使用xhr.responseText获取

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
  • 2021-10-12
  • 2021-09-14
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-01-20
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案