codegeek codegeek - 1 month ago 22
jQuery Question

How to Paginate json response data

I am currently working on a application ,where i will make a call to a url and get JSON response.i am using Handlebars.js to create a list li and finally append it to a ul. since the json reponse is huge , the requirement is to display the data in a pagination format.can you guys please guide me how to show the li's in a pagination format.

<!DOCTYPE html>
<title> Pagniate json data </title>
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<ul class="list-group">


<script src=""></script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
<script src="" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- Handlebars.js -->
<script src=""></script>
<!-- Handlebar Template for creating the list -->
<script id="list-group-item-template" type="text/template" >
{{#each this}}
<li class="list-group-item"> {{ title }} </li>
//removing the first element from the response array
var template = Handlebars.compile($('#list-group-item-template').html());
var list = template(data);


In that case it would be better to do pagination on server side. Otherwise you can store json in local storage and perform pagination. Clear local storage after this request is completed