-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-blog.html
More file actions
35 lines (30 loc) · 890 Bytes
/
ajax-blog.html
File metadata and controls
35 lines (30 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ajax Blog</title>
</head>
<body>
<h1>My Ajax Blog!</h1>
<div id="posts"></div>
<!--jQuery Script CDN-->
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
let content = "";
$.get('data/blog.json').done(function(data) {
console.log(data);
for(let i = 0; i <= data.length - 1; i++) {
content += "<div>";
content += "<h1>" + data[i].title + "</h1>";
content += "<p>" + data[i].content + "</p>";
content += "<p>" + data[i].categories.join(', ') + "</p>";
content += "<p>" + data[i].date + "</p>";
content += "</div>";
}
$("#posts").html(content);
})
})
</script>
</body>
</html>