开发者

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>&nbsp</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>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Stundenlohn</td><td>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Festlohn</td><td>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Bonus</td><td>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Kassenminus</td><td>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Nachtzuschlag</td><td>&nbsp</td><td>&nbsp</td></tr> 
<tr> 
<td class='first'>Sonstiges</td><td>&nbsp</td><td>&nbsp</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>

&nbsp;<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&nbsp;&nbsp;

Stundenlohn&nbsp;&nbsp;

Festlohn&nbsp;&nbsp;

Bonus&nbsp;&nbsp;

Kassenminus&nbsp;&nbsp;

Nachtzuschlag&nbsp;&nbsp;

Sonstiges&nbsp;&nbsp;

</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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜