sami
sami

Reputation: 1362

facebook blocked my json request

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Doers Inc | The one who does something</title>
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $(function () {
            $.ajax({
                url: "http://query.yahooapis.com/v1/public/yql",
                dataType: "jsonp",
                success: function (data) {
                    console.log(data.query.results.json);
                    $.each(data.query.results.json.entries, function (i, v) {
                        $('#entries').append(data.query.results.json.entries[i].content + '<br />');
                     });
                 }, data: {
            q: 'select * from json where url="https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"',
            format: "json"
                    }
           });
       });
   });


</script>
  </head>
  <body>
    <div id="entries"></div>
  </body>
</html>​

I used above code to fetch my facebook posts using json+jquery.but when i add the code to the html file in my site here .the output is showing

​ 

sign.what is the problem for this code or any problem ?

Upvotes: 0

Views: 286

Answers (2)

Dr.Flink
Dr.Flink

Reputation: 572

You have some whitespace before the DOCTYPE-declaration, try to remove it. Also, declare a charset for your page:

UTF-8:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

ISO-8859-1:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Upvotes: 1

CharliePrynn
CharliePrynn

Reputation: 3080

Those characters are not coming from facebook, they are in your code. Which are breaking your javascript.

Here it is working after fixing the code: http://jsfiddle.net/KubtF/

view-source:http://doers.lk/post.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Doers Inc | The one who does something</title>

    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>


    <script type="text/javascript">
    $(document).ready(function(){
 $(function () {
    $.ajax({
        url: "http://query.yahooapis.com/v1/public/yql",
        dataType: "jsonp",
        success: function (data) {
            console.log(data.query.results.json);
            $.each(data.query.results.json.entries, function (i, v) {
                $('#entries').append(data.query.results.json.entries[i].content + '<br />');
            });
        }, data: {
            q: 'select * from json where url="https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"',
            format: "json"
        }
    });
});
​
​  });
    </script>


    </head>
    <body>

<div id="entries"></div>​



    </body>
    </html>

Upvotes: 2

Related Questions