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.
views:
34answers:
2
+3
A:
Wrap it in a div, and:
$("#myDiv").load("/some/url.php"); // where url.php outputs the entire table
You can specify a portion of the remote document to insert by putting it's selector with the URL parameter as follows:
$("#myDiv").load("/some/url.php #myTable");
karim79
2010-02-17 10:51:18
+3
A:
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.
Tatu Ulmanen
2010-02-17 10:52:43