1

According to this topic: Follower count number in Twitter

I'm using this code:

<script>
jQuery.ajax({
url: "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=stackoverflow",
dataType : 'jsonp',
crossDomain : true
}).done(function(data) {
console.log(data[0]['followers_count']);

jQuery('#followers_count').append(followers_count).digits($);
});</script>

And this:

<span id="followers_count"></span>

To retrieve the followers count from Twitter Rest API, but it's not working. I'd like to know if there is any way to retrieve that data, using REST or not, and with jQuery only. No php, only javascript, JSON or jQuery. Is it possible to use any javascript library for that? I can't use php, got my own reasons.

Community
  • 1
  • 1
User325313
  • 79
  • 9

1 Answers1

1

I think your issue is that you are appending an unidentified variable followers_count is not defined anywhere.

var followers_count = data[0]['followers_count'];
jQuery('#followers_count').append(followers_count);

https://jsfiddle.net/0oj49ks7/

Sam Battat
  • 5,725
  • 1
  • 20
  • 29
  • Please make an answer including the full code, using `jQuery.ajax` instead of `$.ajax`, because I using this inside Joomla and Joomla will always launch an error like "undefined" something. Other people may also experience the same problem. Your code works great, flawless. Thank you very much, have just marked your answer as the best answer. – User325313 Aug 30 '16 at 23:59
  • jsfiddle has the full code, you just need to replace $ with jQuery – Sam Battat Aug 31 '16 at 16:42