【发布时间】:2016-05-07 16:45:28
【问题描述】:
为什么responseType 是空的?
JavaScript
var xhr = new XMLHttpRequest();
xhr.open(method,url,true);
xhr.onreadystatechange = function()
{
if (xhr.readyState=='4')
{
if (xhr.status==200)
{
console.log(xhr.responseType);//[empty]
}
}
}
PHP
header('Content-Type: application/json');
//[Validated JSON Data]
没有框架。
【问题讨论】:
-
Empty 表示空字符串?
-
xhr 的 console.log 显示 responseType 的存在?
-
浏览器支持是......未知:developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/…
-
阅读规范似乎你必须在发送请求之前分配给这个属性。不确定该信息是发送到服务器还是只是让客户端对响应执行转换。