I’m getting book info from two different Google Books bookshelves via the API and trying to put it into my custom HTML, but not everything is displaying, and it seems to be because my functions are firing out of sequence, even though I have them laid out in the order I want them and everything is inside $ready. Do I need to use callbacks somehow?
Here is my fiddle: http://jsfiddle.net/bbrLv/
Here is a shot of the console showing the steps firing out of order: http://min.us/mQ0LNVYYT
$.getJSON(), as one of the
$.ajax-based functions of jQuery, implements the powerful Promise interface. That means you can actually make these calls chained with $.then() method, by something like this:UPDATE: Here’s an updated fiddle. I’d have to put a quick hack there: pubdateFixer function. You’ve put it into
$(function(){})form within the second getJSON handler, but that’s not correct: the function should fire exactly after the getJSON content arrives, and not when the initial page gets loaded.