Javascript JQuery表排序器ajax更新
我在更新表时遇到问题。我使用jquerytablesorter的插件。排序工作,但分页不工作Javascript JQuery表排序器ajax更新,javascript,jquery,ajax,tablesorter,Javascript,Jquery,Ajax,Tablesorter,我在更新表时遇到问题。我使用jquerytablesorter的插件。排序工作,但分页不工作 $(function () { $("#myTable").tablesorter(); $('#topicT').on('click', 'a', function () { var href = $(this).attr('href'); var id = href.replace('#', ''); $.ajax({
$(function () {
$("#myTable").tablesorter();
$('#topicT').on('click', 'a', function () {
var href = $(this).attr('href');
var id = href.replace('#', '');
$.ajax({
url: 'faqs',
type: 'POST',
data: {topicId: id},
success: function (response) {
var html = '';
$.each(response, function (key, val) {
html += '<tr><td>' + val.question + '</td></tr>'
});
$('#myTable tbody').empty().append(html);
$('#myTable').trigger('update');
var sorting = [
[0, 0]
];
$('#myTable').trigger('sorton', [sorting]);
}
});
});
});
$(函数(){
$(“#myTable”).tablesorter();
$('topicT')。在('click','a',函数(){
var href=$(this.attr('href');
var id=href.replace('#','');
$.ajax({
url:“常见问题解答”,
键入:“POST”,
数据:{topicId:id},
成功:功能(响应){
var html='';
$。每个(响应、功能(键、val){
html+=''+val.question+''
});
$('#myTable tbody').empty().append(html);
$('#myTable')。触发器('update');
变量排序=[
[0, 0]
];
$('#myTable').trigger('sorton',[sorting]);
}
});
});
});
当我改变
$(“#myTable”).tablesorter()代码>
到
$(“#myTable”).tablesorter({widthFixed:true,widgets:['zebra']}).tablesorterPager({container:$(“#pager”)})代码>
桌子坏了
错误:无法读取未定义的属性“length”。数据不会加载到表中。有人能帮我解决这个问题吗?问题解决了。添加了jquery-migrate-1.2.1.js。
工作代码:
$(function () {
$("#myTable").tablesorter();
$('#topicT').on('click', 'a', function () {
var href = $(this).attr('href');
var id = href.replace('#', '');
$.ajax({
url: 'faqs',
type: 'POST',
data: {topicId: id},
success: function (response) {
var html = '';
$.each(response, function (key, val) {
html += '<tr><td>' + val.question + '</td></tr>'
});
$('#myTable tbody').empty().append(html);
$('#myTable').trigger('update');
$("#myTable").tablesorter({widthFixed: true, widgets:['zebra']}).tablesorterPager({container: $("#pager")});
var sorting = [
[0, 0]
];
$('#myTable').trigger('sorton', [sorting]);
}
});
});
});
$(函数(){
$(“#myTable”).tablesorter();
$('topicT')。在('click','a',函数(){
var href=$(this.attr('href');
var id=href.replace('#','');
$.ajax({
url:“常见问题解答”,
键入:“POST”,
数据:{topicId:id},
成功:功能(响应){
var html='';
$。每个(响应、功能(键、val){
html+=''+val.question+''
});
$('#myTable tbody').empty().append(html);
$('#myTable')。触发器('update');
$(“#myTable”).tablesorter({widthFixed:true,widgets:['zebra']}).TableSorterPage({container:$(“#pager”)});
变量排序=[
[0, 0]
];
$('#myTable').trigger('sorton',[sorting]);
}
});
});
});