Tablesort使用Ajax在Click上重新加载表数据?

时间:2013-07-22 19:10:21

标签: javascript ajax tablesorter

我正在尝试在用户点击链接时重新加载表格数据(行/ TR),我可以添加更多/追加?数据但我似乎无法在插入新表数据之前删除旧表数据。 (顺便说一句:updatetable.php包含该表的所有(TR))

这是我正在尝试做的事情:

$(function() {


$("#append").click(function() { 

var test;
   $.get('updatetable.php', function(data) {
      test = data;
$("#tablesorter-demo").remove();
$("#tablesorter-demo").append(test);
$("#tablesorter-demo").trigger.update(); // <--- I think that error is here, I tried to take out the trigger. but it still doesn't work ?

alert(test);

//return false; 

   });
});

href代码为:<a id="append" href="#">Refresh Page</a>

2 个答案:

答案 0 :(得分:4)

试试这个:

$(function() {

    $("#append").click(function(e) { 

        e.preventDefault();

        $.get('updatetable.php', function(data) {
            $("#tablesorter-demo").find('tbody').html('').append(data);
        });

    });

});

答案 1 :(得分:2)

@Adam Putinski如果一个人正在使用Internet Explorer,那么看起来这个代码将无法使用表格和行显示但是没有其他任何东西可以用它们完成,也就是$('[title!=“”]') .qtip({ });只有在用户从updatetable.php页面加载数据后才能工作,那么它将不再起作用了吗?