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

210
Views
How can I add dots between page numbes in Laravel AJAX results

I'm paginating my results which are displayed through AJAX request but I'm facing a problem with the pagination. Here's my pagination logic:

if(reviews.pagination.next_page_url != null || reviews.pagination.current_page != 1) {

    var paginat = "";

    for (let p = 1; p <= reviews.pagination.last_page; p++) { 

        if (p === reviews.pagination.current_page) {
            paginat = paginat + '<span aria-current="page"><b class="active">' + p + '</b></span>';
        } else { 
            paginat = paginat + '<b>' + p + '</b>';
        }

    }
 
}

Here is an image what happens when the results are too many. How to minify this with .. (dots) between the page numbers?

This is how I return pagination info:

return response()->json([
    'pagination' => collect($reviews->toArray())->except('data'),
   // ....
]);
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!