16
我看到了一些与ajax交叉域的例子,但它不起作用。跨域jquery得到
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<script type="text/javascript" >
$(document).ready(function() {
var url = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=AssasNet&include_rts=1";
$.get(url, function (data) {
console.log(data)
alert(data);
});
});
</script>
</body>
</html>
我尝试对铬和给出以下错误:
XMLHttpRequest cannot load http://api.twitter.com/1/statuses/user_timeline.json?screen_name=AssasNet&include_rts=1. Origin null is not allowed by Access-Control-Allow-Origin.
你从哪里得到这个例子?这是不正确 – 2013-03-12 18:47:29
你必须专门设置外部服务器以使用这种方式使用跨域AJAX,这是你不能在这里做的。 [请使用JSON-P代替。](http://api.jquery.com/jquery.getJSON/) – Blazemonger 2013-03-12 18:47:35
也只有声明。不是一个真正的问题。刚刚建议“错误在哪里” – 2013-03-12 18:50:04