ajax传递包含图片的from表达,从AJAX请求另一个域中获取图像数据(Get image data from another dom...

我想从一个AJAX请求另一个域中获得的图像的二进制数据。 我尝试了各种方法,但没有有效的解决方案。 我发现在互联网上的一些代码,看起来很不错,但即使有这样的要求,我得到的错误。

什么是我错了? 有没有一种标准化的方式来做到这一点?

这里是我试过至今:

var request = this.createCORSRequest('GET', 'http://url/to/image.png');

request.onload = function () {

var text = request.response;

};

request.onerror = function (error) {

alert('Woops, there was an error making the request.');

};

request.send();

private createCORSRequest(method, url) {

var xhr: XMLHttpRequest = new XMLHttpRequest();

if ("withCredentials" in xhr) {

// Check if the XMLHttpRequest object has a "withCredentials" property.

// "withCredentials" only exists on XMLHTTPRequest2 objects.

xhr.open(method, url, true);

} else if (typeof XDomainRequest != "undefined") {

// Otherwise, check if XDomainRequest.

// XDomainRequest only exists in IE, and is IE's way of making CORS requests.

var xdhr = new XDomainRequest();

xdhr.open(method, url);

} else {

// Otherwise, CORS is not supported by the browser.

xhr = null;

}

return xhr;

}

我甚至发现没有Ajax在这里计算器这个解决方案,但它不为我工作:

异步加载图像与jQuery

这里一个错误事件包含的属性的屏幕:

6c1555302777729326ca3efa0910d9ec.png

我的目标是从一个url这是我从一个Atom提要获取得到的图像的二进制代码。 我需要的二进制文件复制图片MS SharePoint中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值