【问题标题】:Get binary data with XMLHttpRequest in a Firefox extension在 Firefox 扩展中使用 XMLHttpRequest 获取二进制数据
【发布时间】:2012-11-04 07:33:07
【问题描述】:

我正在尝试从我的 Firefox 扩展下载一些二进制数据。当我尝试将创建的 XMLHttpRequest 设置为 arraybuffer 模式时:

oHTTP = new XMLHttpRequest();   
oHTTP.responseType = "arraybuffer";

错误

InvalidStateErr
An attempt was made to use an object that is not, or is no longer, usable

被抛出。

还有其他方法可以在 Firefox 扩展中下载二进制数据吗?

【问题讨论】:

    标签: javascript ajax firefox firefox-addon


    【解决方案1】:

    您必须先调用open 方法。

    【讨论】:

    • 简单的答案。但很有帮助。
    • 但是基于 webkit 的,比如最新的 Chrome 或 Opera 稳定版(2015 年 2 月 25 日),当我将 xhr.open() 放在 xhr.responseType = "arraybuffer" 之后的某个位置时,请不要吝啬。为什么会这样?
    • @paa,@spaffy,这是一个错误吗?
    • 在使用axios时如何先调用open方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多