javascript - Using jQuery with reddit API, trying to create seperate divs for each post -


the problem is, posts titles, urls, permalinks separately. need title link , etc each post together.

here code:

   $(document).ready(function() {    $.getjson(     "http://www.reddit.com/r/pics.json?jsonp=?",     function foo(data) {       $.each(         data.data.children.slice(0, 10),         function(i, post) {           $("#reddit-title").append('<br>' + '<div class="post-title">' + post.data.title + '</div>');           $("#reddit-url").append('<br>' + '<div class="post-url">' + post.data.url + '</div>');           $("#reddit-permalink").append('<br>' + '<div class="post-permalink">' + post.data.permalink + '</div>');           $("#reddit-ups").append('<br>' + '<div class="post-ups">' + post.data.ups + '</div>');           $("#reddit-downs").append('<br>' + '<div class="post-downs">' + post.data.downs + '</div>');           $("#reddit-hr").append('<hr>');         }       )     }   )   .success(function() { alert("second success"); })   .error(function() { alert("error"); })   .complete(function() { alert("complete"); });  }); 

here outputs: /r/pics has reached 9 million subscribers, becoming third subreddit , first image based sub beginning p reach milestone

tron mustang

his claw stuck in screen, he's trying play cool

when life comes view

i think found stargate

a happy baby orca breaches surface

aurora on finland

a couple years, thousands of sticky notes, thousands of playing cards, thousands of flash cards, , many many pieces of paper later.

the trunk of rainbow eucalyptus (not photoshopped)

this guy's mushroom hunt success

http://www.reddit.com/r/pics/comments/3edbsk/rpics_has_reached_9_million_subscribers_becoming/

//i.imgur.com/j2xis80.jp

://i.imgur.com/odoruzk.jp

//i.imgur.com/zm7kjvd.jp

/i.imgur.com/0tnk4yj.jp (had make these not valid links posting purposes)

://i.imgur.com/nhrgsb8.jp

://i.imgur.com/jywoted.jp

h//imgur.com/a/namq

://i.imgur.com/jhfz2al.jp

//imgur.com/c0kpfx

/r/pics/comments/3edbsk/rpics_has_reached_9_million_subscribers_becoming/

/r/pics/comments/3eco7r/tron_mustang/

/r/pics/comments/3ebyag/his_claw_is_actually_stuck_in_the_screen_but_hes/

/r/pics/comments/3ebfdh/when_life_truly_comes_into_view/

/r/pics/comments/3ebq5b/i_think_i_found_stargate/

/r/pics/comments/3eb4gi/a_very_happy_baby_orca_breaches_the_surface/

/r/pics/comments/3eb121/aurora_over_finland/

/r/pics/comments/3ebzcu/a_couple_years_thousands_of_sticky_notes/

/r/pics/comments/3ec758/the_trunk_of_a_rainbow_eucalyptus_not_photoshopped/

/r/pics/comments/3ec03u/this_guys_mushroom_hunt_was_a_success/

8

4501

5471

5301

3847

5449

4904

1409

1125

1185

0

0

0

0

0

0

0

0

0

0

i think you'll need add new element contains title, url, permalink, etc. each item. right sounds have 1 element each field need 1 per item field.

also, ids should changed classes since there multiple elements same i'd otherwise. selectors '.reddit-title' instead of '#reddit-title'


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -