google book api

Posted by ohana on Stack Overflow See other posts from Stack Overflow or by ohana
Published on 2010-04-15T23:23:35Z Indexed on 2010/05/15 13:14 UTC
Read the original article Hit count: 466

Filed under:
|

hi, i need to add google's book preview button in my web app. I tried Google Book Search APIs, and used their dynamic links, and added the following in my jquery code:

var cburl = "http://books.google.com/books";
var api_url = cburl + "?jscmd=viewapi&bibkeys=" + "0321525566";
document.write(unescape("%3Cscript src=" + api_url + " type='text/javascript'%3E%3C/script%3E"));

from firebug, i can see google responsed:

var _GBSBookInfo = {"0321525566":{"bib_key":"0321525566","info_url":"http://books.google.com/books?id=VBRePgAACAAJ\u0026source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=VBRePgAACAAJ\u0026cd=1\u0026source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=VBRePgAACAAJ\u0026printsec=frontcover\u0026img=1\u0026zoom=5\u0026sig=ACfU3U2i79GUit7BKFSvfvuZ1daX4EpZjg","preview":"noview","embeddable":false}};

however jquery complaint 'No _GBSBookInfo is defined'.

then i tried jquery's ajax as blow instead of Document.write():

$.ajax({ 
url:api_url,
success: function(_GBSBookInfo) {
alert(_GBSBookInfo);
alert('load was performed');
}
});

still got the same complaint...anyone can help?

© Stack Overflow or respective owner

Related posts about google-books

Related posts about jQuery