Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="answerPlaceHolder"></div>
- <script>
- var placeHolder = $('#answerPlaceHolder');
- var url = 'https://api.vk.com/method/wall.get?owner_id=-78812318&count=20&filter=all&v=5.45';
- var answer;
- $.ajax ({
- url:url,
- type:'get',
- crossDomain:true,
- dataType:'jsonp',
- success:function(response) {
- answer = response;
- var counter = 1;
- answer.response.items.forEach(function(item) {
- // console.log('Пост № ' + counter);
- if ((item.text != 'undefined') && (item.text != '')) {
- placeHolder.append('<div class="blog-header">' + item.text + '</div>');
- //console.log(item.text);
- }
- // console.log(item);
- if ((typeof(item.attachments) != = 'undefined') &&
- (item.attachments[0].type == 'photo') &&
- (typeof(item.attachments[0].photo.photo_604) != = 'undefined')) {
- placeHolder.append(
- '<img width="560px;" src="' + item.attachments[0].photo.photo_604 + '"> <div class="blog-share"><a href="http://gamer-by-life.com/share/?title=' + item.text + '&img=' + item.attachments[0].photo.photo_604 + '&time=' + item.date + '"><img src="share.png"></a></div>'
- );
- // console.log(item.attachments[0].photo.photo_604);
- }
- counter++;
- console.log('******************************n');
- placeHolder.append('<br>');
- });
- },
- error:
- function(error)
- {
- console.log('Ошибка');
- console.log(error);
- }
- });
- </script>
- <div class="blog-header">Тут текст (когда он есть) </div><img width="560px;" src="картинка"><br>
- <div class="post"><div class="blog-header">Тут текст (когда он есть) </div><img width="560px;" src="картинка"><br></div>
- //...
- answer.response.items.forEach(function(item) {
- // console.log('Пост № ' + counter);
- var post = $("<div class='post'>");
- placeHolder.append(post);
- if ((item.text != 'undefined') && (item.text != '')) {
- post.append('<div class="blog-header">' + item.text + '</div>');
- //console.log(item.text);
- }
- // console.log(item);
- if ((typeof(item.attachments) !== 'undefined') &&
- (item.attachments[0].type == 'photo') &&
- (typeof(item.attachments[0].photo.photo_604) !== 'undefined')) {
- post.append('<img width="560px;" src="' + item.attachments[0].photo.photo_604 + '"> <div class="blog-share"><a href="http://gamer-by-life.com/share/?title=' + item.text + '&img=' + item.attachments[0].photo.photo_604 + '&time=' + item.date + '"><img src="share.png"></a></div>');
- // console.log(item.attachments[0].photo.photo_604);
- }
- counter++;
- console.log('******************************n');
- post.append('<br>');
- });
- //...
- placeHolder.append('<div class="post"><div class="blog-header">' + item.text + '</div></div>');
Add Comment
Please, Sign In to add comment