我正在研究使用closure framework(https://github.com/google/shaka-player)的JavaScript应用程序。关闭js框架 - 将ArrayBuffer转换为字符串
我收到一个带有403响应的ajax响应,我需要解析出响应主体以确定细节。
的xhr_.responseType设置为arraybuffer - 所以我希望能够到响应转换成字符串读取其内容:
if (this.xhr_.responseType == 'arraybuffer')
{
var ab = new Uint8Array(this.xhr_.response);
console.log(this.xhr_.response);
console.log(ab);
}
建设与封闭框架,我得到以下错误:
./build/../build/../lib/util/ajax_request.js:441: ERROR - actual parameter 1 of Uint8Array does not match formal parameter
found : *
required: (Array.<number>|ArrayBuffer|ArrayBufferView|null|number)
var ab = new Uint8Array(this.xhr_.response);
所以我发现它不可能将响应传递到Uint8Array的构造函数。有没有办法让响应保持安静?
感谢,但我的问题是,变种AB =新Uint8Array(this.xhr_.response);失败了。 – 2015-04-03 12:29:11