ajax请求:
$.get("http://chengxiaokong.com/index.html", function (data) {
alert("1");
});
报错:
http://chengxiaokong.com/index.html中添加了
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
```也没用。
是什么原因呢
跨域需要在后端解决,前端处理不了
你要是想把这个http://chengxiaokong.com/index.html 嵌套在自己的页面商可以用iframe
跨域的话后端解决很方便,前端东西太多,而且不方便,你请求的html里面内容是啥
dataType:jsonp 加上试试
$.get("http://chengxiaokong.com/index.html", {}, function (data) {
alert("1");
},
"jsonp"
);
$.ajax({
url: "http://chengxiaokong.com/index.html",
data: {},
success: function (data) {
alert("1");
},
dataType:"jsonp"
});