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

  • Home
  • SEARCH
  • 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 8848837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:29:54+00:00 2026-06-14T12:29:54+00:00

I’m using a script called autobrowse It represents an infinite scroll type of script

  • 0

I’m using a script called autobrowse It represents an infinite scroll type of script which pulls the data from a JSON file. When I set the script to repeat(loop) the items a few times it works perfectly like in the demo example from the creator of the script. That is done by entering a higher value in max, like they have it set to 100 in their example which pulls data from a flickr json feed.

But I don’t want to repeat my results, instead I want them to load like every 10 or 20 items and stop when the last item from the json(database) is loaded. But when I set the “max: 1” option in the script in order to load my items from the JSON only once, it displays all the elements at once, no matter how many they are. No infinite scrolling whatsoever.

So I want to set how many items should be displayed with every scroll at the bottom of the page. Like 10 for example.

This is how I generate my JSON file:

<?php
$link = mysql_pconnect("localhost", "user", "pass") or die("Could not connect");
mysql_select_db("dbase") or die("Could not select database");

$arr = array();

$rs = mysql_query("SELECT * FROM bannersright ORDER BY HdOrder");

while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}

echo '{"bannersright":'.json_encode($arr).'}';

?>

And this is how I call the autobrowse script in my view file:

   $(function () {

        $("#wrapper #sidebar-right").autobrowse(

            {

                url: function (offset)
                {                   
                    return "http://www.mysite.com/json.php";
                },
                template: function (response)
                {
                    var markup='';
                    for (var i=0; i<response.bannersleft.length; i++)
                    {
                        markup+='<a href="'+response.bannersleft[i].URL+'"><img src="'+response.bannersleft[i].Image+'" /></a>'
                    };
                    return markup;
                },
                itemsReturned: function (response) { return response.bannersleft.length; },
                offset: 0,
                max: 1,
                loader: '<div class="loader"></div>',
                useCache: false,
                expiration: 1
            }
        );

});

I believe that it has something to do with the offset function, but not sure how to accomplish this. They have one more demo with twitter on their website, which is pretty similar with this, but they call the json like this:

url: function (offset)
{
    return "http://twitter.com/status/user_timeline/ParisHilton.json?count=10&page=OFFSET&callback=?".replace(/OFFSET/, 1+Math.round(offset/10));
},

(the reason their demo doesn’t work any more is because twitter changed their json feeds api)

From the way they call the twitter feed, I suppose twitter had the option to set pages in their API.

So I guess my final question would be: how do you create pages in JSON ? What php code do I need to add to my json.php file in order to be able to pickup the elements from it in pages?

It doesn’t have to be with json pages, if you have another solution please kindly share it.

  • 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-14T12:29:54+00:00Added an answer on June 14, 2026 at 12:29 pm

    You forget to set LIMIT in mySQL request and in url generator:

    PHP

    <?php
    $link = mysql_pconnect("localhost", "user", "pass") or die("Could not connect");
    mysql_select_db("dbase") or die("Could not select database");
    
    //GET page/count
    $count=10;$offset=0;
    if (isset($_GET['count'])) $count=$_GET['count']*1;
    if (isset($_GET['page']))  $offset=$_GET['page']*$count*1;
    
    $arr = array();
    
    $rs = mysql_query("SELECT * FROM bannersright 
                       ORDER BY HdOrder 
                       LIMIT $offset,$count"); #<-HERE
    
    while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;
    }
    
    echo '{"bannersright":'.json_encode($arr).'}';
    
    ?>
    

    JS:

    $(function () {
    
            $("#wrapper #sidebar-right").autobrowse(
    
                {
    
                    url: function (offset)
                    {                   
                        return "http://www.mysite.com/json.php?count=10&page="
                               +Math.round(offset/10); // <-- AND HERE
                    },
                    template: function (response)
                    {
                        var markup='';
                        for (var i=0; i<response.bannersleft.length; i++)
                        {
                            markup+='<a href="'+response.bannersleft[i].URL+'"><img src="'+response.bannersleft[i].Image+'" /></a>'
                        };
                        return markup;
                    },
                    itemsReturned: function (response) { return response.bannersleft.length; },
                    offset: 0,
                    max: 1,
                    loader: '<div class="loader"></div>',
                    useCache: false,
                    expiration: 1
                }
            );
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.