how do I make the list in the json loop thru all the books by using jquery $.eac
ID: 3748105 • Letter: H
Question
how do I make the list in the json loop thru all the books by using jquery $.each or do you think there is something better?
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Milestone 1</title>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js">
</script>
</head>
<body>
<div id="itEbooks">
<p>Sample Data:</p>
</div>
</body>
<body>
<script>
//fetches information about a specific book
var bookData;
$.ajax({
url: "http://it-ebooks-api.info/v1/search/modern%20web"
}).done(function(data) {
for (var book in data) {
$('#itEbooks').append("<p>" + data[book].title + "(" + book + ")<p>");
}
});
</script>
</body>
</html>
Explanation / Answer
If you have any doubts, please give me comment...
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Milestone 1</title>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js">
</script>
</head>
<body>
<div id="itEbooks">
<p>Sample Data:</p>
</div>
</body>
<script>
//fetches information about a specific book
var bookData;
$.ajax({
url: "https://openlibrary.org/api/books?bibkeys=ISBN:0201558025,LCCN:93005405&format=json&jscmd=data "
}).done(function(data) {
$.each(data, function(id, book) {
$('#itEbooks').append("<p>" + id + "(" + book.title + ")<p>");
});
});
</script>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.