Implemenitng Infinite Scrolling with jquery

Using jquery: Implemenitng Infinite Scrolling with jquery on newest questions tagged jquery – Stack Overflow

I am working on a project that uses the jQuery Masonry and Infinite Scroll plugins to load “n” amount of pictures from instagram using their API. Looking at this short example my understanding is that I need to have before hand the html pages to be rendered:

<nav id="page-nav">
  <a href="pages/2.html"></a>

The problem is, I dont really know how many pictures will be retrieved. Here is for example how I retrieve 20 pics at a time.

        var access_token = location.hash.split('=')[1];

        if (location.hash) {

            type: "GET",
            dataType: "jsonp",
            cache: false,
            url: "",
            success: function(data) {

                for (var i = 0; i < 20; i++) {
            $("#instafeed").append("<div class='instaframe'><a target='_blank' href='" +[i].link +"'><img src='" +[i].images.standard_resolution.url +"' /></a></div>");   


        } else {



I guess I will need a pagination mechanism but based on the tutorial mentioned above I believe I will first need to pre-define the html pages to be loaded. So now here my questions

  1. Does that mean this plugin (Infinite Scroll) requires to have “n” amount of html files in a directory to achieve infinite scrolling?
  2. Is it possible to implement infinite scrolling with the same plugin if I dont know how many pages I will have. Even better without even having to create physical html files?
  3. How can this kind of pagination is implemented? (i.e loading chunks of 20 pics as long as the user keeps scrolling down) there is not that much documentation online, could you provide a short step through demo or description?

With kind regards

See Answers

Using jquery: using-jquery

Leave a Reply