跨域问题

当一个域名从另一个域名调取文件时出现如下

XMLHttpRequest cannot load http://www.xxx.com/header_data.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://shuju.xxx.com' is therefore not allowed access. The response had HTTP status code 404.

解决办法如下:

location / {

...

add_header Access-Control-Allow-Origin *;     #允许所有域名调取,当然这里的'*'号你可以设置指定的域名

...

}

posted @ 2015-08-18 11:03  xiaohui163  阅读(206)  评论(0编辑  收藏  举报