MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

XMLHttpRequest.responseText

这篇翻译不完整。请帮忙从英语翻译这篇文章

草案
本页尚未完工.

XMLHttpRequest.responseText 属性返回一个DOMString,它包含对文本的请求的响应,如果请求不成功或尚未发送,则返回null。The responseText property will have the partial response as it arrives even before the request is complete. 如果 XMLHttpRequest.responseType 的值不是 text 或者空字符串,届时访问 XMLHttpRequest.responseType 将抛出 InvalidStateError 异常。

Example

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

// If specified, responseType must be empty string or "text"
xhr.responseType = 'text';

xhr.onload = function () {
    if (xhr.readyState === xhr.DONE) {
        if (xhr.status === 200) {
            console.log(xhr.response);
            console.log(xhr.responseText);
        }
    }
};

xhr.send(null);

Specifications

Specification Status Comment
XMLHttpRequest Living Standard WHATWG living standard

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support ? ? ?[1] ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ? ?

[1] Before IE 10, the value of XMLHttpRequest.responseText could be read only once the request was complete.

文档标签和贡献者

 此页面的贡献者: xgqfrms-GitHub, Dcfm
 最后编辑者: xgqfrms-GitHub,