json - jQuery get data based on value -


i trying json data shown below dribble api using jquery, works @ first, trying append second page of json index... how second page kind of json data?

 {   "page": "1",   "per_page": 15,   "pages": 50,   "total": 750,   "shots": [{     "id": 1155601,     "title": "vector rocket icon",     "height": 600,     "width": 800,     "likes_count": 0,     "comments_count": 1,     "rebounds_count": 0,     "url": "http://dribbble.com/shots/1155601-vector-rocket-icon",     "short_url": "http://drbl.in/iltf",     "views_count": 4,     "rebound_source_id": 1152826,     "image_url": "http://dribbble.s3.amazonaws.com/users/45269/screenshots/1155601/vector-rocket-icon-color.jpg",     "image_teaser_url": "http://dribbble.s3.amazonaws.com/users/45269/screenshots/1155601/vector-rocket-icon-color_teaser.jpg",     "image_400_url": "http://dribbble.s3.amazonaws.com/users/45269/screenshots/1155601/vector-rocket-icon-color_1x.jpg",     "player": {       "id": 45269,       "name": "spovv",       "location": "bulgaria",       "followers_count": 2721,       "draftees_count": 2,       "likes_count": 1293,       "likes_received_count": 13218,       "comments_count": 273,       "comments_received_count": 996,       "rebounds_count": 40,       "rebounds_received_count": 35,       "url": "http://dribbble.com/spovv",       "avatar_url": "http://dribbble.s3.amazonaws.com/users/45269/avatars/original/avatar.png?1329240931",       "username": "spovv",       "twitter_screen_name": "spovv",       "website_url": "http://www.behance.net/s-pov",       "drafted_by_player_id": 47973,       "shots_count": 114,       "following_count": 385,       "created_at": "2011/07/12 07:44:15 -0400"     },     "created_at": "2013/07/15 03:41:04 -0400"   }, {     "id": 1155600,     "title": "ella shadow ",     "height": 600,     "width": 800,     "likes_count": 1,     "comments_count": 0,     "rebounds_count": 0,     "url": "http://dribbble.com/shots/1155600-ella-shadow",     "short_url": "http://drbl.in/ilte",     "views_count": 2,     "rebound_source_id": 1106103,     "image_url": "http://dribbble.s3.amazonaws.com/users/357571/screenshots/1155600/elluva_shadow.yellow.png",     "image_teaser_url": "http://dribbble.s3.amazonaws.com/users/357571/screenshots/1155600/elluva_shadow.yellow_teaser.png",     "image_400_url": "http://dribbble.s3.amazonaws.com/users/357571/screenshots/1155600/elluva_shadow.yellow_1x.png",     "player": {       "id": 357571,       "name": "elluva design studio",       "location": "san francisco, ca",       "followers_count": 13,       "draftees_count": 0,       "likes_count": 21,       "likes_received_count": 63,       "comments_count": 5,       "comments_received_count": 10,       "rebounds_count": 2,       "rebounds_received_count": 0,       "url": "http://dribbble.com/elluva",       "avatar_url": "http://dribbble.s3.amazonaws.com/users/357571/avatars/normal/ella-480.png?1373396866",       "username": "elluva",       "twitter_screen_name": "elluva",       "website_url": "http://www.elluva.co",       "drafted_by_player_id": 3413,       "shots_count": 4,       "following_count": 9,       "created_at": "2013/06/26 02:39:33 -0400"     },     "created_at": "2013/07/15 03:41:03 -0400"   } 

jquery:

             function doajax(){                 $.ajax({                     type:'get',                     url: $url,                     datatype: 'json',                     success: function(data){                         $.each(data.shots, function(key, value){                             // first page only.                             alert(data.page)                            $('#data ul').append('<li><img src="'+ value.image_url+'" /></li>');                                                     })                          //alert(value.title);                         // scroll second page.                         var scrolling = function() {                              this.totalheight = $(document).height();                                 this.scrolltop = $(window).scrolltop();                              $(window).scroll(function(){                                 totalheight = $(document).height();                                 scrolltop = $(window).scrolltop();                                 if((totalheight - scrolltop) < 600){                                     // append different pages , ajax.                                     doajax();                                 }                             })                         }                         $scroll = new scrolling();                         //$('#data').append(data);                     }                 })             }             doajax(); 

use javascript session variables. store page1 json in session. use in second page , concat page1 , page2 json.

concat done follows.

var merger_json = page1_json.concat(page2_json);


Comments