compcobalt
compcobalt

Reputation: 1362

Tablesort Reload Table Data on Click using Ajax?

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)

Here is what I'm trying to do:

$(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; 

   });
});

The href code is: <a id="append" href="#">Refresh Page</a>

Upvotes: 1

Views: 552

Answers (2)

msvuze
msvuze

Reputation: 1397

@Adam Putinski Not if one is using Internet Explorer then it looks like this code will not work the table and rows show but nothing else can be done with them, also the $('[title!=""]').qtip({ }); will only work until the user loads the data from the updatetable.php page then it will not work anymore ?

Upvotes: 1

Adam Putinski
Adam Putinski

Reputation: 457

Try this:

$(function() {

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

        e.preventDefault();

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

    });

});

Upvotes: 3

Related Questions