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