json
  • rss
  • feed
  • google-feed-api
  • 2015-04-01 57 views 1 likes 
    1

    我正嘗試使用Google Feed API加載Feed,但我無法獲取最新記錄。下面我曾嘗試:Google Feed API JSON輸出不顯示最新記錄

    <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

    你試過把你的AJAX URL粘貼到瀏覽器中嗎? – 2015-04-01 10:57:20

    +0

    使用一些REST客戶端添加爲Firefox和測試REST網址.... – 2015-04-01 11:00:44

    +0

    您的AJAX調用成功,但返回null。 – 2015-04-01 11:04:04

    回答

    0

    你被錯誤編碼q網址查詢參數,並有一個與callback參數有問題。試試這個URL代替:

    https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http://www.propertyguru.com.sg/news-rss/SG-PM 
    
    +0

    我還沒有收到最新的記錄 – 2015-04-01 11:28:11

    +0

    將上面的網址粘貼到瀏覽器中,告訴我你看到了什麼。 – 2015-04-01 11:29:41

    +0

    我可以看到「2015年2月5日」的記錄,並且網址有「2015年4月1日」的最新記錄 – 2015-04-01 11:42:08

    相關問題