JohnDotHR JohnDotHR - 10 months ago 70
jQuery Question

Getting thumbnails from a JSON

I need this script to be able to pull out thumbnails from the Google API JSON, for some reason, it doesn't seem to be working. Attached a jsfiddle as wel.l

<div id="book-shelf">

$(function() {
var i=0;
var googleApi = "";
var googleData;
$.getJSON(googleApi, function(json) {
googleData = json;


function setData(){
var j = googleData.length > (i + 9) ? (i + 9) : googleData.length;
for (; i < j; i++) {
var googleThumb = googleData[i].thumbnail;
var img = $('<img style="width: 250px; height: 250px;" src="' + googleThumb + '"/>')

$('#load').click(function() {


As @squint suggests, you can replace callback=handleResponses with callback=? in the API URL, to let jQuery handle the callback (because you haven't created any handleResponses function).

You also need to change this:


into this:


Fixed JSFiddle