Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:25:45+00:00 2026-06-17T20:25:45+00:00

I’m loading images through JSON into #photographs. It initially loads 10 shots and when

  • 0

I’m loading images through JSON into #photographs. It initially loads 10 shots and when you scroll down to a certain point (using waypoints), it should ‘refresh’ the JSON feed so that an extra 5 shots are loaded. I’m using the // &per_page=’ + itemsLoaded // for this in the JSON URL. It’s the var itemsLoaded that gets updated with +5, everytime the waypoint is hit.

See code:

var itemsLoaded = 10;    

$.getJSON('http://api.flickr.com/services/rest/?format=json&method=flickr.photosets.getPhotos&photoset_id=' + photoset_id + '&per_page=' + itemsLoaded + '&page=1' + '&api_key=' + apiKey + '&user_id=' + userId + '&jsoncallback=?', function (data) {
$.each(data.photoset.photo, function (i, flickrPhoto) {
    var basePhotoURL = 'http://farm' + flickrPhoto.farm + '.static.flickr.com/' + flickrPhoto.server + '/' + flickrPhoto.id + '_' + flickrPhoto.secret + "_b.jpg";
    var basePhotoURLMobile = 'http://farm' + flickrPhoto.farm + '.static.flickr.com/' + flickrPhoto.server + '/' + flickrPhoto.id + '_' + flickrPhoto.secret + "_z.jpg";
    var flickrLink = "http://www.flickr.com/photos/" + data.photoset.owner + "/" + flickrPhoto.id + "/";

    var $img = $("<img/>").attr("src", basePhotoURL);
    var $imgMobile = $("<img/>").attr("src", basePhotoURLMobile);
    var $wrap = $("<div class='item'></div>");
    $(".item:nth-child(9n)").addClass("tenth");

    if($(window).width() < 501) {
        $wrap.append($imgMobile);
    } else {
        $wrap.append($img);
    }

    $wrap.append("<a href='" + basePhotoURL + "'.jpg' title='View full size' class='zoom' rel='enroll' />");
    $wrap.append("<a href='" + flickrLink + "' class='flickr' title='View on Flickr' target='_blank' />");
    $wrap.appendTo('#photographs');
});



var loaded = 0;
var totalAmount = $('#photographs .item').length;

    $('#photographs .item img').each(function() {
        loaded;
        $(this).imagesLoaded(function($images) {
            loaded++;
            var percentage =  parseInt((loaded / 11) * 100);
            console.log(loaded + ' van de ' + totalAmount);
            $("#bigloader").progressbar({
               value: percentage
            });
            if(loaded == 10) {
                $("#photographs, #loader").fadeIn("fast");
                $("#bigloader, #preloading").fadeOut("fast");
                $("#photographs").gridalicious({
                    gutter: 2,
                    animate: true,
                    effect: 'fadeInOnAppear',
                    width: 430
                });
                $('.item.tenth').waypoint({
                  triggerOnce: true,
                  handler: function(){
                    console.log("arrived at trigger");
                    itemsLoaded = itemsLoaded + 5;
                  }, 
                  offset: '50%'
                });
            } else if (loaded == totalAmount) {
                $("#loader").fadeOut("fast");       
            };
        });
    });

Extra explanation:

The itemsLoaded var gets updated with a +5 value, each time a waypoint has been hit. The itemsLoaded is the key to my number of items loaded through JSON; so that JSON feed needs to get refreshed.

Basically, how can i update my existing JSON feed with an updated variable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:25:46+00:00Added an answer on June 17, 2026 at 8:25 pm

    In order to make a new call to the flickr API, you need to wrap your “$.getJSON” method in a function that you can call again when the waypoint is hit.
    I believe you also have an error, in that you are appending the elements to the container, but you want to append the next 10 elements rather than retrieve all the same elements plus 5. And so I would suggest that you use a variable that references the page to be loaded from the flickr API instead of the amount of elements to be loaded.

    I believe you are using the jquery waypoint plugin, you can see in fact that in this example only the next items are being retrieved and appended to the container element. I believe that is what you are trying to do, because you are doing an append to the container element. So I would suggest to use a variable that references the page to be retrieved rather than the amount of elements to be retrieved. The amount of elements will always be 10, but you will retrieve the next page of 10 elements and append them to the container.

    Changing this variable, the solution to your problem is as simple as this:

    function refreshJSON(pageLoaded){
      $.getJSON('http://api.flickr.com/services/rest/?format=json&method=flickr.photosets.getPhotos&photoset_id=' + photoset_id + '&per_page=10&page=' + pageLoaded + '&api_key=' + apiKey + '&user_id=' + userId + '&jsoncallback=?', function (data) {
        $.each(data.photoset.photo, function (i, flickrPhoto) {
          var basePhotoURL = 'http://farm' + flickrPhoto.farm + '.static.flickr.com/' + flickrPhoto.server + '/' + flickrPhoto.id + '_' + flickrPhoto.secret + "_b.jpg";
          var basePhotoURLMobile = 'http://farm' + flickrPhoto.farm + '.static.flickr.com/' + flickrPhoto.server + '/' + flickrPhoto.id + '_' + flickrPhoto.secret + "_z.jpg";
          var flickrLink = "http://www.flickr.com/photos/" + data.photoset.owner + "/" + flickrPhoto.id + "/";
    
          var $img = $("<img/>").attr("src", basePhotoURL);
          var $imgMobile = $("<img/>").attr("src", basePhotoURLMobile);
          var $wrap = $("<div class='item'></div>");
          $(".item:nth-child(9n)").addClass("tenth");
    
          if($(window).width() < 501) {
              $wrap.append($imgMobile);
          } else {
              $wrap.append($img);
          }
    
          $wrap.append("<a href='" + basePhotoURL + "'.jpg' title='View full size' class='zoom' rel='enroll' />");
          $wrap.append("<a href='" + flickrLink + "' class='flickr' title='View on Flickr' target='_blank' />");
          $wrap.appendTo('#photographs');
      });
    
    
    
      var loaded = 0;
      var totalAmount = $('#photographs .item').length;
    
      $('#photographs .item img').each(function() {
          $(this).imagesLoaded(function($images) {
              loaded++;
              var percentage =  parseInt((loaded / 11) * 100);
              console.log(loaded + ' van de ' + totalAmount);
              $("#bigloader").progressbar({
                 value: percentage
              });
              if(loaded == 10) {
                  $("#photographs, #loader").fadeIn("fast");
                  $("#bigloader, #preloading").fadeOut("fast");
                  $("#photographs").gridalicious({
                      gutter: 2,
                      animate: true,
                      effect: 'fadeInOnAppear',
                      width: 430
                  });
                  $('.item.tenth').waypoint({
                    triggerOnce: true,
                    handler: function(){
                      console.log("arrived at trigger");
                      pageLoaded++;
                      refreshJSON(pageLoaded);
                    }, 
                    offset: '50%'
                  });
              } else if (loaded == totalAmount) {
                  $("#loader").fadeOut("fast");       
              };
          });
      });
    }
    
    refreshJSON(1); // we start by loading the first page
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JSon response to parse title,date content and thumbnail images and place
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
this is what i have right now Drawing an RSS feed into the php,
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.