is not allowed by Access-Control-Allow-Origin.
<html>
<head>
<script type="text/javascript" src="jquery-1.8.2.js"></script>
<script type="text/javascript">
// we will add our javascript code here
$(document).ready(function() {
$.get('http://baidu.com', function(data) {
console.log(data);
});
console.log("Sample of data33:");
});
</script>
</head>
<body>
<!-- we will add our HTML content here -->
<a href="">Link</a>
</body>
</html>
Chrome console: Sample of data33: dd.html:11 XMLHttpRequest cannot load http://baidu.com/. Origin http://192.168.7.14:88 is not allowed by Access-Control-Allow-Origin.
3 回复
curl http://baidu.com 就可以,什么区别?
跨域了,浏览器的Same-Origin策略,具体可以google下
遇到这种情况怎么处理呢?我想到的一种:在server端定时curl获取baidu.com,然后brower再用ajax调用自己server端的数据。不过这样很耗服务器资源啊。