I've been sitting with this for hours now, and I cant understand why.
q
is working. The URL does give me a proper JSON-response. It shows up as objects and arrays and whatnot under the JSON tab under the Net-tab in Firebug and all is fine. I've also tried with other URLs that i know work. Same thing happens.I have another function elsewhere in my tiny app, wihch works fine, and is pretty much exactly the same thing, just another API and is called from elsewhere. Works fine, and the
data
variable is filled when it enters the getJSON-function. Here,data
never gets filled with anything.I've had breakpoints on every single line in Firebug, with no result. Nothing happens. It simply reaches the getJSON-line, and then skips to the debugger-statement after the function.
var usedTagCount = 10; var searchHits = 20; var apiKey = "a68277b574f4529ace610c2c8386b0ba"; var searchAPI = "http://www.flickr.com/services/rest/?method=flickr.photos.search&" + "format=json&api_key=" + apiKey + "&sort=interestingness-desc&per_page=" + searchHits + "&jsoncallback=?&nojsoncallback=1&tags="; var tagString = ""; var flickrImageData = new Array(); function search(query) { for(var i = 0; i < usedTagCount; i++) { tagString += query[i].key + ","; }
}var q = searchAPI + tagString; $.getJSON(q, function(data) { debugger; /* It never gets here! */ $.each(data.photos.photo, function(i, item) { debugger; flickrImageData.push(item); }); }); debugger; return flickrImageData;
Example of request URL (q
):
http://www.flickr.com/services/rest/?method=flickr.photos.search&format=json&api_key=a68277b574f4529ace610c2c8386b0ba&sort=interestingness-desc&per_page=20&jsoncallback=?&tags=london,senior,iphone,royal,year,security,project,records,online,after,
I do wonder, since JSONView (the firefox plugin) cannot format it properly, that it isn't really JSON that is returned - the mime-type is text/html. Firebug, however, interprets it as JSON (as i stated above). And all the tag words come from another part of the app.