Take the 2-minute tour ×

I have this strange issue I can't overcome apparently, I am trying to retireve a Twitter JSON feed using the script tag at the bottom of my page:

<script src="http://api.twitter.com/1/statuses/user_timeline/haunted85.json?count=15&callback=listTweets" type="text/javascript"></script>

I want the data to be handed over a callback function I have named listTweets. The thing is if I load my page and try to get the output in my Chrome console tab via javascript function, then I get a Failed to load resource error, but if I manually copy and enter the URI in the address bar, I am returned all the Twitter data in the browser. What am I missing here?

share|improve this question
Does listTweets get called at all? Try and inspect the "Network" tab in Chrome Inspector/Firebug. Did the twitter API call return 200 OK? I dynamically inserted that script element into this StackOverflow page, and it successfully called listTweets. –  Julian H. Lam Apr 7 '13 at 17:34
I just tried it locally and it tries to call listTweets, both running as localhost and as a local file. Whereabouts are you including the script? –  Lewis Apr 7 '13 at 17:38
listTweets doesn't get called at all because there's no event triggering it, I suspect and I've just looked in the Network tab and the twitter api returns just (failed) with no error code. –  haunted85 Apr 7 '13 at 17:38
@Lewis I am including it just before the closing </body> tag at the end of my page. I have also tried to place it elsewhere in the page, but no change whatsoever. –  haunted85 Apr 7 '13 at 17:40
Why don't you use a standard JSONP-Call to fetch the data? Works just fine: jsfiddle.net/hDy3Y –  m90 Apr 7 '13 at 17:41
show 7 more comments


Your Answer



Browse other questions tagged or ask your own question.