jquery - Facebook阻止了我的JSON请求

标签 jquery html facebook json error-handling

 <!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>​

我使用上面的代码使用json + jquery来获取我的Facebook帖子。但是当我将代码添加到站点here中的html文件中时,输出显示
​ 

sign.this代码是什么问题或任何问题?

最佳答案

这些字符不是来自facebook,它们在您的代码中。哪些破坏了您的JavaScript。

修复代码后,它在这里工作:
http://jsfiddle.net/KubtF/

查看源代码: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>

关于jquery - Facebook阻止了我的JSON请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13952429/

相关文章:

javascript - jQuery 下拉值根据变量而变化

javascript - 带下拉菜单的菜单按钮

html - 元素的 z-index 但是不同的定位?

javascript - .className() 似乎不起作用

javascript - 如何仅在文档加载时显示 UL 中的前 3 个元素?

javascript - 获取 anchor /哈希值的索引

html - Flex 布局中的动态列宽

facebook - Xamarin.Android 可以使用哪个 facebook SDK?

java - Android facebook webdialog 网络错误 (netstack : lib_mgr error)

javascript - 什么是 channel 文件?