I'm in need of some help, I want to make a simple rss feed that reads off of a website like arstechnica. I've researched and looked around for the past couple of hours but I'm a little confused on the proper way to do something like this. I'm currently attempting to do it how I would access json data. This may be entirely wrong but, below is sample code I have so far. I thank you for your time.
我需要一些帮助,我想制作一个简单的RSS提要,读取像arstechnica这样的网站。我已经研究过,看了几个小时,但我对这样做的正确方法感到有些困惑。我目前正在尝试如何访问json数据。这可能完全错误,但下面是我到目前为止的示例代码。我感谢你的时间。
<html>
<head>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
//rss
function LoadRss()
{
var feed;
$(document).ready(function() {
$.ajax({
url: "http://feeds.arstechnica.com/arstechnica/index?format=xml",
dataType: 'xml',
contentType: 'application/xml',
success: function(data){
$('#feed').html(data);
}
});
});
}
LoadRss()
setInterval( LoadRss, 30000);
</script>
</head>
<body>
<div id="feed"></div>
</body>
</html>
1 个解决方案
#1
0
Are you not missing one argument?
你不是错过了一个论点吗?
contentType: 'application/xml',
Please try it.
请试一试。
And don't forget about
别忘了
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
so you can use jQuery.ajax()
.
所以你可以使用jQuery.ajax()。
Still you will be probably struggling with CORS
Cross-Origin, so maybe instead you could use <iframe>
?
你仍然可能会遇到CORS Cross-Origin,所以也许你可以使用
and
location.reload()
in
setInterval(function(){location.reload()}, 30000);
Like this:
<html>
<head>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
setInterval(function(){location.reload()}, 30000);
</script>
</head>
<body>
<iframe style="width: 800px; height: 800px;" src="http://feeds.feedburner.com/ArsTechnica?format=xml"></iframe>
</body>
</html>
Hope this helps.
希望这可以帮助。
#1
0
Are you not missing one argument?
你不是错过了一个论点吗?
contentType: 'application/xml',
Please try it.
请试一试。
And don't forget about
别忘了
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
so you can use jQuery.ajax()
.
所以你可以使用jQuery.ajax()。
Still you will be probably struggling with CORS
Cross-Origin, so maybe instead you could use <iframe>
?
你仍然可能会遇到CORS Cross-Origin,所以也许你可以使用
and
location.reload()
in
setInterval(function(){location.reload()}, 30000);
Like this:
<html>
<head>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
setInterval(function(){location.reload()}, 30000);
</script>
</head>
<body>
<iframe style="width: 800px; height: 800px;" src="http://feeds.feedburner.com/ArsTechnica?format=xml"></iframe>
</body>
</html>
Hope this helps.
希望这可以帮助。