1

我正在尝试使用 Google Feed API 加载提要,但无法获取最新记录。我在下面尝试过:

<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>
4

1 回答 1

0

您错误地对 url 查询参数进行了编码q,并且该callback参数存在问题。试试这个网址:

https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http://www.propertyguru.com.sg/news-rss/SG-PM
于 2015-04-01T11:21:33.850 回答