-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_blog.html
65 lines (57 loc) · 2.58 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Blagh</title>
<link rel="stylesheet" href="css/bootstrap.css">
<style>
.panel-footer {
height: 50px;
}
</style>
</head>
<body>
<nav class="navbar navbar-default"><div></div></nav>
<div class="container">
<div class='center-block row' id="posts">
<div class="panel panel-primary">
<div class="panel-heading">Fake post for sake of testing.jpgexelol</div>
<div class="panel-body"> test </div>
<div class="panel-footer">
<div class="col-xs-6">December 21st, 2808</div><div class="col-xs-6 text-right">tag,tag,tag</div>
</div>
</div>
</div>
<form action="POST">
<div class='center-block row' id="posts">
<div class="panel panel-primary">
<div class="panel-body">
<div class="form-group"><input type="text" class="form-control" id="title" placeholder="title"></div>
<div class="form-group"><input type="text" class="form-control" id="content" placeholder="content"></div>
<div class="form-group"><input type="text" class="form-control" id="date" placeholder="date"></div>
<div class="form-group"><input type="text" class="form-control" id="tags" placeholder="tags"></div>
</div>
</div>
</div>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
function calldata(){$.ajax("data/blog.json").done(function(data){
console.log(data);
$(data).each(function(postnum){
var title = data[postnum].title;
var content = data[postnum].content;
var categories = data[postnum].categories;
var date = data[postnum].date;
$('#posts').append("<div class='panel panel-primary'><div class='panel-heading'>" + title + "</div><div class='panel-body'>" + content + "</div><div class='panel-footer'><div class='col-xs-6'>" + date + "</div><div class='col-xs-6 text-right'>" + categories + "</div> </div> </div>")
})
})}
$.ajax("http://www.giantbomb.com/api/game/3030-4725/?api_key=094a304a6f7c3553d68a4dcbcc4bf58cf67c7681&format=json&field_list=genres,name").done(function(data){
console.log(data);
});
calldata();
</script>
</body>
</html>