javascript - JSON request returning undefined, not an error -
function searchgames(query) { // send off query $.ajax({ url: gamessearchurl, type : "get", data: { query : query, resources: "game", format: "jsonp", crossdomain: true, limit: 16, field_list : "description,name,image", json_callback : "returngames", sort : "original_release_date:desc" }, datatype: "jsonp" }); }; /* reference: http://stackoverflow.com/questions/22918573/giantbomb-api-work */ /* reference: http://www.giantbomb.com/forums/api-developers-3017/api-request-with-jsonp-uncaught-syntaxerror-1492639/ */ // callback when results function returngames(data) { $('div#display').append('found ' + data.total + ' results ' + data.query); var games = data.game; $.each(games, function(index, game) { $('div#display').append('<h1>' + game.name + '</h1>'); $('div#display').append('<p>' + game.description + '</p>'); $('div#display').append('<img src="' + game.image + '" />'); }); }
functions listed above, understand jsonp data should passed returngames function, output on page found undefined results undefined. console shows no errors?
i'm using giantbomb api. variables query , gamesearchurl defined global variables @ top of document. console.log in function shows variables have been passed correctly.
Comments
Post a Comment