2

i was trying to get the facebook feeds in json using the jquery....

this is the script i am trying to achive the data

    $(function () {
    $.ajax({
        url: 'http://www.facebook.com/feeds/page.php?id=237173582992285&format=JSON',
        type: 'get',            
        dataType: "jsonp",          
        success: function (data) {
            alert("data successfully came ");
        }, error: function (data) {
            alert("fail to get the data");                
        }
    });
});

jsfiddle Example

i have trace in mozila firefox.in console data is returning in json format...

data is not binding in success method.. data is binding in error method..

please check this above snapshot attached here

enter image description here

Prasad Raja
  • 685
  • 1
  • 9
  • 37
  • After some testing and fiddling with the browser console ("Syntax error" in page.php?), I suspect the JSONP data format might be wrong, like here: http://stackoverflow.com/a/19456236/1781026 – chrki Mar 04 '14 at 12:49
  • i can find the syntax error.. so how can i achive this feeds ? if i replace the /* dataType: "jsonp" */ to /* dataType: "json" */ ....no data is returning in this....give me solution to re-solve this issue.. – Prasad Raja Mar 04 '14 at 13:00

1 Answers1

1

That URL doesn't allow for JSONP type requests because it doesn't wrap the JSON in a callback. You can however proxy the request through Googles feeds API, which can do cross-origin-resource loading.

<script>
  function jsapi_loaded(){
    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed(
        "https://www.facebook.com/feeds/page.php?format=rss20&id=237173582992285"
      );
      feed.setNumEntries(10);
      feed.load(function(result) {
        if (!result.error) {
          console.log(result);
        }
      });
    }
    google.setOnLoadCallback(initialize);
  }
</script>
<script src="https://www.google.com/jsapi?callback=jsapi_loaded" async></script>
Kit Sunde
  • 35,972
  • 25
  • 125
  • 179