Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML:
- <head>
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- </head>
- <body>
- <section class="media book showcase" data-isbn="0553283685">
- <header>
- <h3 class="title"></h3>
- <h4 class="author"></h4>
- <h4 class="publisher"></h4>
- </header>
- <img src="" alt="" class="thumbnail" />
- </section>
- <script src="//nla.pusta.cf/tes/books-google.js"></script>
- </body>
- JAVASCRPT >> books-google.js :
- var isbn = $('.book').data('isbn');
- $.ajax({
- dataType: 'json',
- url: 'https://www.googleapis.com/books/v1/volumes?q=isbn:' + isbn,
- success: handleResponse
- });
- function handleResponse( response ) {
- $.each( response.items, function( i, item ) {
- var title = item.volumeInfo.title,
- author = item.volumeInfo.authors[0],
- thumb = item.volumeInfo.imageLinks.thumbnail;
- $('.title').text( title );
- $('.author').text( author );
- $('.thumbnail').attr('src', thumb);
- });
- }
Add Comment
Please, Sign In to add comment