I am using backbone.js, and trying to fetch some json from twitter, but it doesn't work, the collection's length is 0. Here's the code.
var Tweet = Backbone.Model.extend();
var Tweets = Backbone.Collection.extend({
model: Tweet,
url: 'http://api.twitter.com/1/favorites.json?screen_name=dhh',
parse: function(response) {
return response.results;
}
});
var tweets = new Tweets();
tweets.bind('reset', function(tweets) {
alert(tweets.length);
});
tweets.fetch();
favoritesAPI call is more picky about origins - Your code throws anorigin not allowederror from twitter when run on jsFiddle and also fromfile://. Are you running it from the filesystem? Or localhost? Or from a real server? Are you getting an ajax error. Supernova's answer blow is correct as well - the response is just an array - Edward M Smith