我想呈现此url http://online.wsj.com/xml/rss/3_7085.xml使用jquery获取所有的xml信息,但我碰到了jsonp上的东西这给我一个回调,我该如何处理回调来呈现html中的每个节点。想要获取RSS源和呈现在html上使用jquery
我尝试下面的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>RSS Feed testing</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var result;
function jsonparser1() {
$.ajax({
type: "GET",
url: "http://online.wsj.com/xml/rss/3_7085.xml",
dataType: "jsonp",
success: function (result) {
$("div").html(result);
},
});
}
\t
\t $(document).ready(function(e) {
jsonparser1();
});
</script>
</script>
</head>
<body>
<div></div>
</body>
</html>
我一派,约JSONP,其相当混乱给我。
除非wsj启用了CORS,否则它不会因为相同原点策略而发生,并且您无法使JSONP发生,您调用的服务器必须支持它。 – epascarello