Hello! Recently I've been working on a web application that is using JQuery to parse the JSON and display it in the HTML view. I cannot figure out why the table the following code outputs ends the tag immediately after the first .append method.
$("document").ready(function() {
$.getJSON("http://localhost:1909/encoders", function(data) {
$("#displayencoders").append('<table class="encoders"><tr class="rows"><th class="j">Encoder Name</th><th class="j">Status</th></tr>');
$.each(data, function(i, item) {
$("#displayencoders").append("<tr><td>" + item.EncoderName + "</td><td>" + item.EncoderStatus + "</td></tr>");
});
$("#displayencoders").append("</table>");
});
});
The above code will output the HTML below.
<table class="encoders">
<tbody><tr class="rows"><th class="j">Encoder Name</th><th class="j">Status</th></tr></tbody>
</table>
<tr><td>rmcp2-encoder</td><td>inactive</td></tr><tr><td>rmcp2-encvm1</td><td>active</td></tr><tr><td>rmcp2-encvm2</td><td>active</td></tr><tr><td>rmcp2-encvm3</td><td>active</td></tr><tr><td>rmcp2-encvm4</td><td>inactive</td></tr><tr><td>rmcp2-encvm5</td><td>active</td></tr><tr><td>rmcp2-encvm6</td><td>active</td></tr><tr><td>rmcp2-encvm7</td><td>inactive</td></tr><tr><td>rmcp2-encvm8</td><td>inactive</td></tr>
In other words, how can I modify my existing JQuery code to move my tag to the end of the actual table?
Thanks in advance.