首页 > 其他 > 详细

怎样获取从服务器返回的字符串数据

时间:2019-09-20 11:42:41      阅读:94      评论:0      收藏:0      [点我收藏+]

使用: 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获取

 

怎样获取从服务器返回的字符串数据

原文:https://www.cnblogs.com/aisowe/p/11555747.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!