-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_blog.js
66 lines (55 loc) · 1.66 KB
/
ajax_blog.js
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
/**
* Created by Harry on 12/1/16.
*/
var populate = function() {
"use strict";
// post original JSON data
var blogContent = $.get("data/blog.json");
var mainBlog = [];
blogContent.done(function(data) {
data.forEach(function (object) {
mainBlog += '<div class="media">' + '<br>' +
'<div class="media-left">' + '<br>' +
'<img class="media-object" src="' + object.img + '"> </div>' +
'<div class="media-body">' +
'<h3 class="media-heading">' + object.title + '</h3><br>' +
'<p>' + object.date + '</p><br>' +
'<p>' + object.content + '</p>' + '<br>' +
'</div>' + '<br>' +
'</div>'
console.log(object.img);
// mainBlog += "<h2>" + object.title + "</h2><br>"
// + "<p>" + object.content + "</p>"
// + "<img src='" + object.img + ">";
});
$("#posts").html(mainBlog);
});
blogContent.fail(function () {
console.log("There was an error!");
});
blogContent.always(function () {
console.log("Success");
});
};
populate();
// // reload button
// $("#reload").click(function () {
// $.get("data/blog.json");
// populate();
// });
// datepicker function
$( function() {
$("#datepicker").datepicker();
} );
// Add a blog post
// var addPost = function(post){
//
// };
$('#blog-form').serializeArray()
// };
// Remove a blog post
// var removePost = function(index){
// find post in array by index
// splice post out of the array
// remove post element from page
// };