JQuery - Load table and insert it with html()
i want to load a html table in a div
The HTML-Code is loaded via:
$("#table_wrapper").hide();
$.get("<?echo base_url();?>schichtplan/employee_fields/"+plan_id+"true",function(data){
$("#table_wrapper").html(data);
$("#table_wrapper").show();
});
Data is validated via alert and looks like:
<table border= '0'cellpadding='4' cellspacing='0' class='mitarbeiter' />
<thead>
<tr>
<th> </th><th><div id='plan_id:1;sort_id:1' class='edit_employee'>User1</div></th><th><div id='plan_id:1;sort_id:2' class='edit_employee'>User2</div></th></tr>
</thead>
<tbody>
<tr>
<td class='first'>Anstellung</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Stundenlohn</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Festlohn</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Bonus</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Kassenminus</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Nachtzuschlag</td><td> </td><td> </td></tr>
<tr>
<td class='first'>Sonstiges</td><td> </td><td> </td></tr>
</tbody>
</table>
After the JQuery-Action the div looks like:
<div id="table_wrapper" style="display: block; ">开发者_StackOverflow社区<table border="0" cellpadding="4" cellspacing="0" class="mitarbeiter"></table>
<div id="plan_id:1;sort_id:1" class="edit_employee">User1</div><div id="plan_id:1;sort_id:2" class="edit_employee">User2</div>
Anstellung
Stundenlohn
Festlohn
Bonus
Kassenminus
Nachtzuschlag
Sonstiges
</div>
Table-Code is generated with CodeIgniter.
I have no idea why the result looks like that
Some hint?
Thanks
There is a slash at the end of the tag that starts the table. Only some tags can be closed with the slash, and if a tag isn't allowed to have the slash, it will be kept open for the rest of the page, which will make your html invalid. This is what it should look like:
<table border='0' cellpadding='4' cellspacing='0' class='mitarbeiter'>
<thead>
<!-- ... -->
</thead>
<tbody>
<!-- ... -->
</tbody>
</table>
It looks like your Table-Code is rendered NOT COMPLETELY LIKE HTML but table renders like normal view. Check is there any config option for Table-Code module to generate FULL HTML table.
Which method do you use to render table?
Just noticed - the table is self closed on the first line:
<table border= '0'cellpadding='4' cellspacing='0' class='mitarbeiter' />
Should be:
<table border= '0'cellpadding='4' cellspacing='0' class='mitarbeiter' >
I strongly suspect this is your problem sir.
精彩评论