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();
The solution is to get rid of the parse function, which has the same effect as the other answer suggests, and add &callback=?