Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <div id="posts">
- </div>
- </body>
- ==========================================================
- $(document).ready(function() {
- function callpost() {
- var URL = 'http://buchiblog.atwebpages.com/wp-json/wp/V2/posts';
- $.getJSON(URL, function(data) {
- console.log(data);
- updateDOM(data);
- });
- };
- callpost();
- function updateDOM(data) {
- for (i = 0; i < data.length; i++) {
- var excerpt = data[i].excerpt.rendered;
- $("#posts").append("<section></section>");
- };
- $('section').append("<h1></h1>");
- for (j = 0; j < data.length; j++) {
- $('section').append("<div>" + excerpt + "</div>")
- }
- };
- });
Add Comment
Please, Sign In to add comment