paginationjs
paginationjs copied to clipboard
Whether pageSize and pageNumber can be automatically added to the request body
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;
},
//...
});