I made an ajax pagination and for example if I go to page 4 and enter a post and want to go back it goes back to page 1.
but it should go back to page 4 because that's what makes sense. I can't find how to do this
here are my codes;
index.php;
<div id="discountVilla">
<h1>Luxury Villa</h1>
<div id="results"> </div>
<div id="loader"></div>
<div class="clearfix"></div>
</div>
<script type="text/javascript">
function showRecords(perPageCount, pageNumber) {
$.ajax({
type: "GET",
url: "ajax.php",
data: "pageNumber=" + pageNumber,
cache: false,
success: function(html) {
$("#results").html(html);
$('#loader').html('');
}
});
}
$(document).ready(function() {
showRecords(10, 1);
});
</script>
And Ajax.php
<div class="col-lg-12">
<ul class="pagesclass">
<?php
for ($i = 1; $i <= $pagesCount; $i++) {
if ($i == $pageNumber) {
?> <li><a href="javascript:void(0);" class="current" style="background-color: #5a5b90;">
<?php echo $i ?>
</a></li> <?php
} else {
?> <li><a href="javascript:void(0);" class="pages" onclick="showRecords('<?php echo $perPageCount; ?>', '<?php echo $i; ?>');">
<?php echo $i ?>
</a></li> <?php
} // endIf
} // endFor
?>
</ul>
<script>
$(".pages").click(function() {
$('html, body').animate({
scrollTop: $("#discountLuxury").offset().top
}, 'slow');
});
</script>
</div>