首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在XmlHttpRequest readyState 4中调用chrome readyState

在XmlHttpRequest readyState 4中调用chrome readyState
EN

Stack Overflow用户
提问于 2013-11-26 04:40:48
回答 1查看 274关注 0票数 1

我试图从blob响应中保存fileSystem中的图像,但是文件对话框没有显示,这是我的脚本:

代码语言:javascript
复制
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", "http://website.org?url=http://www.google.com");
xhr2.responseType = "blob";
xhr2.onreadystatechange = function() {
    if (xhr2.readyState == 4) {
        console.log(xhr2.response); //Blob {type: "text/xml", size: 17830, slice: function}
        $('img')[0].src=window.URL.createObjectURL(xhr2.response); //response image is showing fine

        console.log($('#mydiv').attr('id')+'.jpg'); //suggestedName is 'web:file.html.jpg'
        chrome.fileSystem.chooseEntry({ type:'saveFile',suggestedName:$('#mydiv').text()+'.jpg',accepts:[{ extensions:['jpg'] }] },function(fileEntry){
        //chooseEntry is not creating file dialog
            console.log(fileEntry); //undefined
        });
    }
};
xhr2.send(null);

Manifest.json

代码语言:javascript
复制
"permissions": [
    "http://www.website.org",
    "syncFileSystem",
    {"fileSystem": ["write", "directory"]}
],
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-26 17:44:37

好吧,我解决了。显然,suggestedName值不能具有字符':‘

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20208643

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档