user3829086 user3829086 - 5 months ago 204
Javascript Question

how to use the dynamic PHP ajax data with the bootpag

How can I display the dynamic content of PHP with bootstrap pagination.The result is displaying using ajax call in div id 'msrResult', how to use that div in bootstrap pagination code. Here my code:

<script src="//"></script>
<script src="//"></script>
<script src="// /lib/jquery.bootpag.min.js"></script>
<link rel="stylesheet" href="//">

<div id="content2">Dynamic Content goes here</div>
<div id="page-selection">Pagination goes here</div>
total: 23,
page: 1,
maxVisible: 10
}).on('page', function(event, num){
$("#content2").html("Page " + num); // or some ajax content loading...

<div id=msrResult></div>


First of all the "space" in the GitHub URL could produce 404 responses. You should delete it to get the script working ;)

Basically (as you can see at the authors website) clicking the page-buttons (they are showing up in #page-selection once the script is initialized correctly) triggers bootpag to toggle the content. In the .on() function you have the chance to place new content right before it shows up again.

In the script you've provided you write "Page X" in #content2 before it shows up. But in your case you want to load dynamic content in this div so you could do something like this:

  url: "source.php?site="+num
}).done(function(data) {
  $( "#content2" ).html( data );

in the .on() function to load the dynamic php content in your #content2 div

Also see this JS fiddle for a demo: