Javascript InnerHTML Table Issues with AJAX

If you need to use Javascript innerHTML to update an element on the page you may run into issues if the element is a table.  The correct way to updated the table element is through a <tbody> tag.  You can then give it an ID that you can get with your javascript.


<tbody id=”updatedContent”> </tbody>

Then you can pass <tr> and <td> data into the <tbody> using innerHTML.

This is the way you will have to update a table using AJAX. without this technique you won’t be able to add or update a table’s data with AJAX.

Source: StackOverflow – add rows to table with innerHTML

You may also like...

Leave a Reply

Your email address will not be published.