所以这是我访问 RSS 提要的测试代码。另外,这是我要解析的 RSS 提要。这不是项目的最终设计,只是试图拼凑起来。
当我使用 c.title,c.link 部分而不是c.description 或 c.pubDate 部分时,它可以工作。它只是说它是未定义的。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>not finished yet</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' >/*
/*
* jGFeed 1.0 - Google Feed API abstraction plugin for jQuery
*
* Copyright (c) 2009 jQuery HowTo
*
* Licensed under the GPL license:
* http://www.gnu.org/licenses/gpl.html
*
* URL:
* http://jquery-howto.blogspot.com
*
* Author URL:
* http://me.boo.uz
*
*/
(function ($) {
$.extend({
jGFeed: function (url, fnk, num, key) {
if (url == null) {
return false;
}
var gurl = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;
if (num != null) {
gurl += "&num=" + num;
}
if (key != null) {
gurl += "&key=" + key;
}
$.getJSON(gurl, function (data) {
if (typeof fnk == "function") {
fnk.call(this, data.responseData.feed);
} else {
return false;
}
});
}
});
})(jQuery);</script>
<script type='text/javascript'>
$(window).load(function () {
$.jGFeed('http://www.scarletknights.com/rss/rss.asp?sportid=1',
function (feeds) {
if (!feeds) {
alert('Trouble getting RSS feed :(');
return false;
}
for (var i = 0; i < feeds.entries.length; i++) {
var entry = feeds.entries[i];
console.log(entry);
// Entry title
$('#results').append('<h1>' + entry.title + '</h1>' + '<br/>');
}
}, 10);
});
</script>
</head>
<body>
<div id="results"></div>
</body>
</html>