Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Jquery Pagination with API fetching"
Bootstrap 4.1.1 Snippet by
Webcentcreations
4.1.1
jQuery
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
1.6K
 
0 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row mt-4 content-center"> <div class="col-md-6"> <ul class="list-group 100_list_container"></ul> </div> </div> <div class="row mt-4 content-center"> <div class="col-md-6"> <ul class="pagination" id="page_container"> </ul> </div> </div> </div>
.content-center{ justify-content:center; } .list-item-contains{ margin-bottom: 1.5em; border: 0; box-shadow: 5px 0px 5px -1px #f6f6f6, 0px 5px 5px 0px #F6F6F4, -5px 0px 5px -1px #f6f6f6, 0px -5px 5px -1px #f6f6f6; border-radius: 5px; }
var total_records = 100; var perpage = 10; var total_pages = total_records / perpage; $(document).ready(function(){ var pagenum = 1; createpagination(pagenum); fetch_data(perpage,pagenum); }); function createpagination(pagenum){ $("#page_container").html(""); if(pagenum == 1){ $("#page_container").append("<li class='page-item disabled previous'><a href='javascript:void(0)' class='page-link'><</a></li>"); }else{ $("#page_container").append("<li class='page-item' onclick='makecall("+(pagenum-1)+")'><a href='javascript:void(0)' class='page-link'><</a></li>"); } var i=0; for(i=0; i <= 2; i++){ if(pagenum == (pagenum+i)){ $("#page_container").append("<li class='page-item disabled'><a href='javascript:void(0)' class='page-link'>"+(pagenum+i)+"</a></li>"); }else{ if((pagenum+i)<=total_pages){ $("#page_container").append("<li class='page-item' onclick='makecall("+(pagenum+i)+")'><a href='javascript:void(0)' class='page-link'>"+(pagenum+i)+"</a></li>"); } } } if(pagenum == total_pages){ $("#page_container").append("<li class='page-item disabled'><a href='javascript:void(0)' class='page-link'>></a></li>"); }else{ $("#page_container").append("<li class='page-item next' onclick='makecall("+(pagenum+1)+")'><a href='javascript:void(0)' class='page-link'>></a></li>"); } } function fetch_data(perpage, pagenum){ $.ajax({ type:'get', url:'https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[per_page]=10&request[page]='+pagenum, dataType:'json', success:function(data){ $(".100_list_container").html(""); $.each( data.plugins, function( key, value ) { $(".100_list_container").append("<li class='list-group-item list-item-contains'><div><h5>"+value.name+"</h5>"+value.version+"</div></li>"); }); }, error:function(){ $(".100_list_container").html("error"); } }); } function makecall(pagenum){ createpagination(pagenum); fetch_data(perpage,pagenum); }
Related:
See More
Free Template
Datepicker
355.2K
276
Table Panel with Pagination
116.6K
104
Rounded Pagination
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76