Last active
July 15, 2017 21:05
-
-
Save petrosh/cbd605d35b474b5b56558a2464d888dc to your computer and use it in GitHub Desktop.
prova jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('p').append($().jquery); | |
$.ajax({ | |
url: "https://cors-anywhere.herokuapp.com/https://www.goodreads.com/search.xml?key=YGezY0bM4jFWGNHR9VAY0A&q=Ender%27s+Game", | |
dataType: "xml", | |
success: function(xml) { | |
data = []; | |
xmlDoc = $.parseXML( xml ); | |
$xml = $( xmlDoc ); | |
works = $(xml).find('work'); | |
$(xml).find('work').each(function(i,r){ | |
data.push({ | |
'title': $(this).find("best_book title").text(), | |
'author': $(this).find("best_book author name").text(), | |
'thumb': $(this).find("best_book small_image_url").text(), | |
'ratings': $(this).find("ratings_count").text(), | |
'stars': $(this).find("average_rating").text(), | |
'reviews': $(this).find("text_reviews_count").text(), | |
'year': $(this).find("original_publications_year").text() | |
}); | |
console.log(data); | |
}); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment