Hey guys, I keep getting this error message on the console and can't print out the data. Any assistance would be greatly appreciated. Thanks
$("#search").submit(function(event){
event.preventDefault();
var userInput = $("#query").val();
getRequest(userInput);
});
function getRequest(userInput){
$.ajax({
url: "http://www.giantbomb.com/api/search",
type: "GET",
data: {
resources: "game",
query: userInput,
api_key: "8cd10a7136710c1003c8e216d85941ace5a1f00e",
format: "jsonp",
crossDomain: true,
limit: 15,
field_list: "platforms,name,image,original_release_date,site_detail_url"
},
dataType: "jsonp"
}).done(function(data){
showResults(data.results);
console.log(data);
});
}
function showResults(result){
var html = "";
$.each(result, function(index,value){
var gameName = value.name;
var boxArt = value.image.icon_url;
var releaseDate = value.original_release_date;
var platform = value.platform.name;
var site_detail = value.platform.site_detail_url;
html += "<li><p>" + gameName + "</p></li>" + "<img src=" +boxArt + ">" + "<p>" + releaseDate + "</p>" + platform + "</p>" + "<a href='" + site_detail + "'><p>Click here for more information</p></a>";
});
$("#search-results").html(html);
}
Log in to comment