<div data-url="http://test.com/image/2019-04-02-17-29-11_DwWPYDNQczKRVwkb3FfJbP.jpeg"></div>
然后我想获取到这张图片用 form 的形式 ajax 提交给服务器:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://test.com/image/2019-04-02-17-29-11_DwWPYDNQczKRVwkb3FfJbP.jpeg', true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
if (this.status == 200) {
var blob = this.response;
// Ajax 提交这个 blob
}
};
xhr.send();
但是在 Chrome 下提示:
Access to XMLHttpRequest at 'http://test.com/image/2019-04-02-17-29-11_DwWPYDNQczKRVwkb3FfJbP.jpeg' from origin 'http://a.lab.test:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
请问这个该如何解决? 谢谢。