var xhr = new XMLHttpRequest();
xhr.open('GET', "http://faceunity.com/static/images/index_bc.jpg", true);
xhr.responseType = "blob";//关键的一步
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var blod = this.response;
console.log(blod)
// var src = URL.createObjectURL(blod);
var eleLink = document.createElement("a");
eleLink.download = name || new Date().getTime() + ".jpg";
eleLink.href = URL.createObjectURL(blod);
document.body.appendChild(eleLink);
eleLink.click();
}
}
};
xhr.send();
jquery返回的数据进行了处理,要用原生的