locked
How to Retrive The Particular Book Details From Google My Library Through ID RRS feed

  • Question

  • User-1080158282 posted
    <html>
      <head>
      </head>
      <body>
        <div id="content"></div>
        <script>
          function handleResponse(response) {
          for (var i = 0; i < response.items.length; i++) {
            var item = response.items[i];
            // in production code, item.text should have the HTML entities escaped.
            document.getElementById("content").innerHTML += "<br>" +item.volumeInfo.title+"<br>"+item.volumeInfo.imageLinks.thumbnail;
          }
        }
        </script>
        <script src="https://www.googleapis.com/books/v1/volumes/buc0AAAAMAJ"></script>
      </body>
    </html>
     
    Here I am Trying to Get Details of The Book Through Specific ID from the Google Books Please Help in JavaScript and JSON
    Friday, December 26, 2014 12:17 AM

All replies

  • User1827201912 posted
    function getBookDetails(id) {
        var xmlhttp = new XMLHttpRequest();
        var url = "https://www.googleapis.com/books/v1/volumes/" + id;
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var item = JSON.parse(xmlhttp.responseText);
                document.getElementById("content").innerHTML += "<br>" + item.volumeInfo.title + "<br>" + "<img src=\""+item.volumeInfo.imageLinks.thumbnail+"\" >";
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send();
    }
    
    getBookDetails("buc0AAAAMAAJ");

    Live demo: http://jsfiddle.net/ocoye944/

    Original code by Garav kalyan
     

    Sunday, December 28, 2014 10:57 PM