Jquery,JSON twitter追随者数 [英] Jquery, JSON twitter followers count
本文介绍了Jquery,JSON twitter追随者数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑以下用于统计 Twitter关注者的脚本。出于某种原因,我会列出两次该列表。我只想为数组中的元素使用跟随者计数统计信息。
Consider the following script which is used for counting twitter followers. For some reason I get the list twice. I just want the follower count stats for the elements in the array. Any help is greatly appreciated.
echo "<div id='twitter'>
<script type='text/javascript'>
$(document).ready(function(){
var i;
twitterusername = ['Sinbg','followfog','miniclip','vgames'];
for(i=0; i<4; i++){
(function(i){
$.getJSON('http://twitter.com/users/' + twitterusername[i] + '.json?callback=?',
function(data){
$('#twitter').html( document.getElementById('twitter').innerHTML + twitterusername[i] + ' ' +
data.followers_count + ' Followers' + '<br/>');
}
) // end getJSON
})(i);
}// end for??
});</script></div>";
推荐答案
将脚本标记移出twitter-div 。
Move the script-tag out of the twitter-div.
Here the example with the script inside.
Here with the script after the div.
这篇关于Jquery,JSON twitter追随者数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文