上点击使用Ajax Tablesort刷新表数据?数据、Ajax、Tablesort

2023-09-11 22:33:06 作者:柔情少年

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

I'm trying to reload the table data (rows/TRs) when the user clicks a link, I can add more/append? the data but I cannot seem to delete the old table data before inserting the new table data. (BTW: the updatetable.php contains all of the (TR's) for that table)

下面是我想要做什么:

$(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 code是:&LT;一个ID =追加的href =#&GT;刷新页面&LT; / A&GT;

推荐答案

试试这个:

$(function() {

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

        e.preventDefault();

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

    });

});
 
精彩推荐
图片推荐