Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether pageSize and pageNumber can be automatically added to the request body #142

Open
gogobosco opened this issue Nov 23, 2023 · 0 comments

Comments

@gogobosco
Copy link

By default, paginationjs appends pageSize and pageNumber to the request url, but my backend api only accepts post requests and needs to place these two parameters in the body.
I tried to use beforePaging to obtain pageNumber and modify the data in ajax's beforeSend, but beforePaging is triggered after beforeSend, the page can only be turned to the last page number each time.
May I ask if there is a solution.

      let queryData = {
        //...
        pageSize: 10,
        pageNumber: 1,
      };
      let url = "http://api/page";
      $("#demo").pagination({
        // api 的 url
        dataSource: url,
        ajax: {
          beforeSend: function (e,settings) {
            console.log("beforeSend");
            settings.data=JSON.stringify(queryData);
          },
          type: "POST",          
          data: {},
          ...
        },
        callback: function (data, pagination) {
          //dataContainer.empty();
          console.log(data);
          $tableData.bootstrapTable(’refreshOptions',{ data: data });
        },
        beforePaging: function (pageNum) {
          console.log("beforePaging");
          queryData.pageNumber = pageNum;
        },
        //...
      });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant