This is my js code.
I am using the latest jQuery and Backbone libraries.
(function(Tweet) {
//Tweet.Model = Backbone.Model.extend();
Tweet.Collection = Backbone.Collection.extend({
url: function() {
return "http://search.twitter.com/search.json?q=twitterapi&callback=?";
},
parse: function(data) {
return data.results;
}
});
Tweet.Views.List = Backbone.Layout.extend({
template: "#list",
events: {
"click li": "update"
},
update: function(ev) {
var index = $(ev.target).index();
var model = this.collection.at(index);
this.trigger("update", model);
},
serialize: function() {
return { tweets: this.collection };
}
});
Tweet.Views.Detail = Backbone.Layout.extend({
template: "#detail",
serialize: function() {
return { tweet: this.model };
}
});
}) (twitter.module("tweet"));
When I run the url http://search.twitter.com/search.json?q=twitterapi&callback=? on my browser, I can see the results.
So I have the connection to twitter.
When I remove the callback=? from the url in my code, I get the Cross Domain error.
So this means that my version of the jQuery and Backbone is updated enough to automatically format my request as a jsonp callback.
But I continuously get a 403 error.
The following is the error as stated by Chrome console in red:
GET http://search.twitter.com/search.json?q=twitterapi&callback=jQuery19107466092116665095_1364193857160&_=1364193857161 403 (Forbidden)
Please help me to understand if I am doing anything wrong on my end?
UPDATE
I have tried the following based on some of the suggestions.
I added this https://github.com/jacebeleren/backbonelayoutmanager/commit/6af9a367cea5bcf460b67319137d6f077b1ff5ec
..and this https://github.com/jacebeleren/backbonelayoutmanager/commit/01cfba1c416673617591b0c936e41a27b93bbf51
but the error persists.
UPDATE 2
These are the request headers that I get for the 403 error.
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:pid=v3:1364189785315637597538615; guest_id=v1%3A136419139351112726; k=10.35.60.125.1364192963733514; __utma=43838368.881187358.1364192967.1364192967.1364192967.1; __utmc=43838368; __utmz=43838368.1364192967.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _twitter_sess=BAh7CToPY3JlYXRlZF9hdGwrCKCsPKA9AToMY3NyZl9pZCIlNzc0NjU5ZmQ5%250AN2Q4MjA0M2RjYzQzMjMyZTFjMDk3ZTkiCmZsYXNoSUM6J0FjdGlvbkNvbnRy%250Ab2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA6B2lkIiUxZTc3%250AMTFiNjcwN2M0OWM0OTVmMDA0ODgxNTQ1MzdkZA%253D%253D--43c3e3ef6a53296eb8f6640c3e9dc21539f18ef6
Host:search.twitter.com
Referer:http://bblm.localhost/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22