Home > Backend Development > PHP Tutorial > ajax跨域访问解决方法

ajax跨域访问解决方法

WBOY
Release: 2016-06-13 12:25:26
Original
944 people have browsed it

ajax跨域访问
已阻止跨源请求:同源策略禁止读取位于 http://zsh.cityhouse.cn/market/ajaxlogin.html?fromurl=http%3A%2F%2Fwwwt.cityhouse.cn%2Fdefault%2Fforsalerank.html%3Fmatchrand%3Da0b92382 的远程资源。(原因:CORS 头缺少 'Access-Control-Allow-Origin')。

从”http://www.b.com“访问”http://www.a.com“的资源,出现如上面的错误提示。

            var loadurl = “http://www.a.com/market/ajaxlogin.html?';
            loadurl += "fromurl="+encodeURIComponent(location.href);          
    $('.popContent').load(loadurl);

请问大家该怎么解决,谢谢~~~

------解决思路----------------------
服务器那边有设置Access-Control-Allow-Origin吗?
参考:http://blog.csdn.net/fdipzone/article/details/46390573
------解决思路----------------------
1. 在服务器端加Header头Access-Control-Allow-Origin;
2. 服务器待调用的方法是否支持JSONP;
3. 如果1,2均不行,老老实实在服务器端使用Curl获取数据,Ajax呈现;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template