Advertisement
LegoDrifter

Untitled

Jan 12th, 2021
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. $(document).ready(function () {
  2. $("#add").click(function () {
  3. getData($("#isbn").val())
  4. })
  5.  
  6. function getData(book_isbn) {
  7. if (book_isbn.length ==10 || book_isbn.length==13){
  8. $.ajax({
  9. url:"https://openlibrary.org/api/books?bibkeys=ISBN:"+book_isbn+"&jscmd=details&callback=mycallback",
  10. dataType: "jsonp",
  11. success: function (data) {
  12. list_item = $("<li></li>")
  13. list_item.append(data["ISBN:"+book_isbn]["details"]["title"])
  14. list_item.attr("image", data["ISBN:"+book_isbn]["thumbnail_url"])
  15. list_item.attr("info", data["ISBN:"+book_isbn]["info_url"])
  16. list_item.attr("publ",data["ISBN:"+book_isbn]["details"]["publishers"])
  17. list_item.appendTo("#books")
  18. }
  19. })
  20. }
  21. }
  22.  
  23. $(document).on("click", "li", function () {
  24. $("#publ").html($(this).attr("publ"))
  25. $("#url").attr("href",$(this).attr("info"))
  26. $("#url").html("Book info")
  27. $("#image").attr("src", $(this).attr("image"))
  28. })
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement