-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax-blog.html
84 lines (50 loc) · 2.06 KB
/
ajax-blog.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- ------------------BootStrap CDN-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N"
crossorigin="anonymous"></script>
<style>
body {
background: url('https://source.unsplash.com/twukN12EN7c/1920x1080') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
</style>
<title>Ajax Store</title>
</head>
<body>
<!-- Header -->
<div id="posts" class="text-center patterns pt1"></div>
<!--JQuery CDN-->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"
integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
<script>
"use strict";
$(document).ready(function () {
$.ajax('data/blog.json')
.done(function (data) {
let html = '';
for (let i = 0; i < data.length - 1; i++) {
html += "<div>";
html += "<h1>" + data[i].title + "</h1>";
html += "<p>" + data[i].content + "</p>";
html += "<p>" + data[i].categories.join(',' + " ") + "</p>";
html += "<p>" + data[i].date + "</p>";
html += "</div>";
}
$('#posts').html(html);
})
})
</script>
</body>
</html>