Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

83
Views
Ajax Pagination Does Not Remember Previous Page

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>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!