No 'Access-Control-Allow-Origin' header is present on the requested resource.

CDN加速后发现问题:
XMLHttpRequest cannot load http://img. domain.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.domain.com' is therefore not allowed access.

其实就是跨域问题,一般解决方案就是使用jsonp,但考虑到改动地方比较多,且jsonp只支持get.

解决方法
在被请求的Response header中加入

// 指定允许其他域名访问
header('Access-Control-Allow-Origin:http://www.domain.com');
// 响应类型
header('Access-Control-Allow-Methods:POST,GET');
// 响应头设置
header('Access-Control-Allow-Headers:x-requested-with,content-type');





posted @ 2016-06-01 09:15  YBID  阅读(343)  评论(0编辑  收藏  举报