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 8540705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:39:44+00:00 2026-06-11T11:39:44+00:00

I am completely new to this, so please forgive me if I don’t get

  • 0

I am completely new to this, so please forgive me if I don’t get enough information. I’m displaying potentially thousands of records using JSON and a listview, however I need to only show 20 at a time, with a “show more” button at the bottom. I’m not understanding how I would change my current javascript to allow for this, hopefully someone can point me in the right direction. I’ve been trying to apply this code to get it to work, but unsuccessfully:

http://jsfiddle.net/knuTW/2/

My current javascript to display the JSON data:

function getEmployeeList() {
$.getJSON(serviceURL + 'getmeals.php?calfrom='+ var1 + '&calto=' + var2, function(data) {
    $('#employeeList li').remove();
    employees = data.items;
    $.each(employees, function(index, employee) {
        $('#employeeList').append('<li><a href="employeedetails.html?id=' + employee.id + '">' +
            '<img src="http://www.restaurants.com/assets/img/logos/' + employee.restaurant + '.jpg"/>' +    
                '<h4>' + employee.meal_item + '</h4>' +
                '<p>Calories: ' + employee.calories + '</p>' +
                '<span class="ui-li-count">' + employee.protein + '</span></a></li>');

    });
    $('#employeeList').listview('refresh');
});
}

HTML:

<div id="employeeListPage" data-role="page" >

<div data-role="header" data-position="fixed">
    <h1>Restaurant Meals</h1>
</div>

<div data-role="content">
     <ul id="employeeList" data-role="listview" data-filter="true"></ul>
     <ul class="load-more"><a href="#">Load More</a></ul>
</div>      

  • 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-11T11:39:46+00:00Added an answer on June 11, 2026 at 11:39 am

    The idea is to add two parameters to your $.getJSON : limit and offset.

    Limit is the number of rows you want. So let’s say 20 rows.

    Offset is the row number where you want to start your search. So 0 then 20 then 40 etc.

    By clicking “get more”, you repeat your $.getJSON with an offset of +20.

    In the backend, your SQL query should look like:

    $query = "SELECT * FROM table LIMIT $offset, $limit";
    

    When the query returns nothing, it means the user reaches the end.

    Then you can hide the “get more” button.


    Another solution is to get all the employees with a single $.GetJSON then store the result in an variable. You start by displaying the first 20 employees. If the user clicks on “get more”, you display the next 20 employees. When there are no more employees in your array, you hide the “get more” button.

    With this solution, you will avoid to make several requests to your server.


    You can also look for a plugin to make your pagination.

    Some examples:

    • https://github.com/beneverard/jqPagination
    • https://github.com/luis-almeida/jPages
    • https://github.com/gbirke/jquery_pagination
    • https://github.com/fedecarg/jquery-paginate
    • https://github.com/wesnolte/Pajinate
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please forgive me if any of this is wrong -I'm completely new to Java.
I am completely new to this game, so please be gentle ;-) I made
First, a caveat: I'm brand new to C#, so please forgive me, if this
I am definitely new to Perl, and please forgive me if this seem like
I'm new to DDD so please forgive me if I'm not using the terms
I'm totally, completely new to programming, so please forgive what is probably a stupid
OK, I'm still quite new to Xcode/Cocoa etc, so please forgive me if this
I'm pretty new to PHP, so please forgive me if this question is obnoxiously
I searched SO before asking this question, I am completely new to this and
Completely new to most of this stuff, but basically Im playing around with the

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.