是否可以将Tablesorter Pager小部件与AJAX POST请求一起使用而不是GET请求?
祝你好运!
答案 0 :(得分:1)
寻呼机小部件与寻呼机插件具有相同的选项,只是在小部件选项前面有pager_
。因此,请将pager_ajaxObject
option包含类型选项设置为“POST”:
$("table").tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter', 'pager'],
widgetOptions: {
// modify the $.ajax object to allow complete control over your ajax requests
pager_ajaxObject: {
dataType: 'json',
type: 'POST'
},
pager_ajaxUrl: 'mysite/data.json?{filterList:filter}&{sortList:column}',
pager_ajaxProcessing: function(data){
if (data && data.hasOwnProperty('rows')) {
return [ data.total, data.rows, data.headers ];
}
}
}
});
这是full list of ajax object settings
更新
$("table").tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter', 'pager'],
widgetOptions: {
// modify the $.ajax object to allow complete control over your ajax requests
pager_ajaxObject: {
dataType: 'json',
type: 'POST',
data : { /* include static data here */ }
},
pager_ajaxUrl: 'mysite/data.php',
// use this to function to modify the pager_ajaxObject
// or include a `beforeSend` callback with the pager_ajaxObject
pager_customAjaxUrl: function(table, url) {
var obj = table.config.widgetOptions.pager_ajaxObject;
obj.sort = table.config.sortList;
obj.filters = $(table).data('lastSearch');
return url; // required to return url, but url remains unmodified
},
pager_ajaxProcessing: function(data){
if (data && data.hasOwnProperty('rows')) {
return [ data.total, data.rows, data.headers ];
}
}
}
});