I have a super simple Backbone model/collection that wraps around a facebook feed.
window.Story = Backbone.Model.extend({});
window.Stories = Backbone.Collection.exten开发者_如何转开发d({
model: Story,
url: 'https://www.facebook.com/feeds/page.php?id=186424828078649&format=json&callback=?',
parse: function(response) {
console.log(response);
return response.entries;
}
});
stories = new Stories();
stories.fetch();
This results in a syntax exception in Chrome ("Unexpected token :"), or in Firefox, an invalid label "title": {
.
The Chrome message is a little cryptic, but the Firefox message seems to indicate that the JSON response is being returned. the parse()
function is never getting called (as far as I can tell, I've set a breakpoint and added a console.log statement and I'm not seeing anything), so is there anything else that Backbone needs to know in order to parse JSON?
My first thought was that it might be a Cross-Domain issue, but I'm using &callback=?
which should make sure that $.ajax uses jsonp. I'm betting that this is working, because Firefox is identifying the 2nd line correctly as "title": {
.
Any ideas?
PS, jsfiddle is at http://jsfiddle.net/KcE9L/ if you'd like to test things out.
I figured it out after some deep debugging. It's because Facebook ignores/doesn't support JSONP, and leaves me with this problem: Jquery success function not firing using JSONP. Now I need to figure out how to get CORS working with Facebook, so if anybody can help me along those lines, I'd be curious.
精彩评论