我正在尝试使用Google Feed API加载Feed,但我无法获取最新记录。我试过以下:
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
url = 'http://www.propertyguru.com.sg/news-rss/SG-PM';
var randomNum = Math.floor((Math.random() * 10000) + 1);
$.ajax({
type: "GET",
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=20&callback=?&q=' + encodeURIComponent(url) + '&nocache=' + (new Date).getTime() + randomNum,
dataType: 'json',
historical: false,
error: function () {
alert("Unable to load feed, Incorrect path or invalid feed");
},
success: function (data) {
alert(JSON.stringify(data, null, "\t"));
}
});
});
</script>
答案 0 :(得分:0)
您错误地编码了q
url查询参数,callback
参数出现问题。请尝试使用此网址:
https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http://www.propertyguru.com.sg/news-rss/SG-PM