Iam having some serious trouble parsing data from Giantbomb. I’ve tried almost every trick in my book to parse the data, but it either gives me Access Origin Null not allowed, or Unexpected : in the Javascript console. I’ve tried both doing this:
$.getJSON("http://api.giantbomb.com/search/?api_key=KEY&query=crash%20bandicoot&field_list=name,image&format=jsonp&json_callback=gamer", function(data) {
console.log(data)
});
And without the JSONP stuff:
$.getJSON("http://api.giantbomb.com/search/?api_key=KEY&query=crash%20bandicoot&field_list=name,image&format=json", function(data) {
console.log(data)
});
Nothing seems to be working – at all. And Google doesn’t seem to have any answers either. Does anybody have a clue what to do?..
My goal is to get cover art from games, so if there’s a better library out there – please let me know!
Two problems with what you’re doing:
If you put
&format=jsonpinto the URL, you’re still not making a JSONP request when you issue it with$.getJSON. Any$.getJSONcalls will just get errors that the call is not allowed due toAccess-Control-Allow-Origin. You need to use$.ajaxand set dataType to JSONP.You have specified a JSON callback function called
gamer. This is where you should be dumping out the data usingconsole.logand doing anything else to parse the result.Something like the following should work: