How can I replace a table with a new one using jQuery?

ajax, javascript, jquery

Solution

If you don't want to add a wrapper element, something like this should work:

$.ajax({
    url: 'yoururl.php',
    success: function(r) {
        $('table#something').replaceWith(r);
    }
});

..assuming the response you get is an table element.

Problem

Whats the best way to replace a `<table>` with a new one using jQuery? I'm using ajax on the page to get the new data.

Original source