私はuniで始まっているプロジェクトのために、特定のFacebookの統計情報を取得するjQuery jsonメソッドを探しています。 trying to pull the number of likes from a facebook fanpage using JSONP and JQueryjsonを使用して複数のページのfacebook好きを引き出す
私のページにコードを使用していて、うまく動作し、軽量ですが、このコードを使用して複数のページから結果を取り込みたいのですが、解決策を見つけようとし、レンガの壁に当たった。
私の現在のコード、1ページのデータを引き込むことである:私は
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
//Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
var url = "https://graph.facebook.com/immbudden?callback=?";
//Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
$.getJSON(url,function(json){
var html = "<ul><li>" + json.likes + "</li><li>" + json.about + "</li></ul>";
//A little animation once fetched
$('.facebookfeed').animate({opacity:0}, 500, function(){
$('.facebookfeed').html(html);
});
$('.facebookfeed').animate({opacity:1}, 500);
});
});
</script>
<link rel="stylesheet" href="style.css" media="all">
</head>
<body>
<div id="wrapper"><!--wrapper open-->
<div class="facebookfeed">
<h2>Loading...</h2>
</div>
</div><!--wrapper closed-->
</body>
文字通り適切にjQueryを掘り下げるために始めていますので、すべての任意のヘルプは大歓迎です!事前に
おかげで、マイケル
ああ、優れた:)感謝を! 1つの質問ですが、各コールバックを使用する方法では、それぞれのIDがそれぞれのdivに表示され、それぞれのfacebookページのイラストやその他の情報が含まれます。このメソッドはこれを許可しますか?もう一度ありがとう:) – Michael
もちろん、各項目をそれ自身のdivとフォーマットに入れてループを編集するだけです:) –
私は今日、指定されたdivに各項目を追加しようとしていますが、正しく機能していないようですここでは、私が試したコードのjsFiddleです:http://jsfiddle.net/immbudden/PRA7b/ 私はおそらく何か愚かなことをやっているが、私のjQueryを読んでそれを動作させるように見えない本や学習のように事前に謝罪しています。 – Michael