daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Apr 26th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <body>
  2.     <div id="posts">
  3.  </div>
  4. </body>
  5. ==========================================================
  6. $(document).ready(function() {
  7.  
  8.     function callpost() {
  9.  
  10.         var URL = 'http://buchiblog.atwebpages.com/wp-json/wp/V2/posts';
  11.  
  12.         $.getJSON(URL, function(data) {
  13.             console.log(data);
  14.             updateDOM(data);
  15.  
  16.         });
  17.  
  18.     };
  19.  
  20.     callpost();
  21.  
  22.     function updateDOM(data) {
  23.         for (i = 0; i < data.length; i++) {
  24.             var excerpt = data[i].excerpt.rendered;
  25.             $("#posts").append("<section></section>");
  26.  
  27.         };
  28.  
  29.         $('section').append("<h1></h1>");
  30.  
  31.         for (j = 0; j < data.length; j++) {
  32.             $('section').append("<div>" + excerpt + "</div>")
  33.         }
  34.  
  35.  
  36.     };
  37.  
  38.  
  39. });
RAW Paste Data
Top