Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1112963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:47:11+00:00 2026-05-17T02:47:11+00:00

I am trying to implement paging across ajax calls. The page should not refresh

  • 0

I am trying to implement paging across ajax calls. The page should not refresh when the user wants to see the next x num of results.

Here is my problem. Returning the QuerySet is super simple. I just do (sumaJson is custom)

data = serializers.serialize('sumaJson', result_page.object_list, relations=('first_major', 'country_of_origin', 'second_major'))
return HttpResponse(data, mimetype="application/json") 

Now I also want to return things like

result_page.has_previous()
result_page.has_next()
result_page.paginator.count

and so on. I for the life of me can’t figure out how to get both across in one response. I can’t add this info to result_page.object_list because then the serializer fails. If I something of the sort of

simplejson.dumps(paging_info + result_page.object_list)

Then in the javascript the QuerySet is no longer a list of objects but just a big string of characters which can’t be interpreted with

$.each(data.data, function(index, item){

I tried some bad hacks like creating a fake object and putting it in the object_list, serializing this and then deleting the object. This allows me to get the data across. However, I don’t want to be creating and deleting fake objects.

I don’t want to meddle with the serializer. I don’t want to send a second ajax request once I get the querySet back to get the paging info.

Am I missing something? Is there an easy way to get both across in one response? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:47:11+00:00Added an answer on May 17, 2026 at 2:47 am

    When I’m serializing a collection of objects, I typically include the pagination information in the response body itself. If I had 50 objects that I wanted to serve up 10 per page, the JSON would look something like this:

    {
        "count": 50,
        "objects": [
            {
                ...
            }
        ],
        "pages": {
            "count": 5,
            "current": "http://api.example.com/objects/?page=3",
            "first": "http://api.example.com/objects/",
            "last": "http://api.example.com/objects/?page=5",
            "next": "http://api.example.com/objects/?page=4",
            "previous": "http://api.example.com/objects/?page=2"
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a DataGrid in ASP.NET, and want to achieve custom paging
i'm trying to implement paging in xml using this code and got around to
I am trying to implement paging in PHP, using Json. I need the data
I am trying to implement paging and i done that. The problem is when
I'm trying to implement paging in a custom ListAdapter. Right now I'm just making
I'm trying to implement a paging and sorting list in ASP.NET MVC without using
I was trying to implement Grouping and paging in silverlight 3's datagrid, I found
I'm trying to implement some simple paging, based on How do I do pagination
I am trying to implement paging for a View in T-SQL : with TH_VW_UserFollowing
Im trying to implement a single aspx page with several externals dll's. Following Zimmergren's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.