javascript - Listing all posts with Blogger API -
i'm trying list blog posts blogger api v3:
<script type="text/javascript"> function handleresponse(response) { var post_number = object.keys(response.items).length; //number of posts (i=0; i<post_number; i++) { $('#content').append('<div id="post' + (i+1) + '" class="post"><p></p></div>'); $('.post p').html(object.keys(response.items[i].title)); } } </script> <script src="https://www.googleapis.com/blogger/v3/blogs/1961645108677548855/posts?callback=handleresponse&key=aizasyajesqb3ddltucdbzif3lunx-gzr18tbrg"></script>
this append 3 divs (because of 3 posts) content div. content of each of divs is:
<p> "1" "2" "3" "4" "5" </p>
i have no clue why, though assume title
attribute of items[]
. solutions or clues?
thanks answers!
you should removed object.keys()
, try this:
<script type="text/javascript"> function handleresponse(response) { var post_number = object.keys(response.items).length; //number of posts (i=0; i<post_number; i++) { $('#content').append('<div id="post' + (i+1) + '" class="post"><p></p></div>'); $('.post p').html(response.items[i].title); } } </script> <script src="https://www.googleapis.com/blogger/v3/blogs/1961645108677548855/posts?callback=handleresponse&key=aizasyajesqb3ddltucdbzif3lunx-gzr18tbrg"></script>
in case shouldn't use object.keys()
Comments
Post a Comment