i've got another problem with my jquery code. Here some example code:
$(document).on('click', 'input.goto_batterie_pruefung', function() {
/** some code**/
$.ajax({
url: "example.php",
type: "post",
data: /* some data */,
datatype: "json",
success: function(data) {
var data=$.parseJSON(data);
$('#div_testausgabe').html('');
$('#div_testausgabe').append('<hr /><table><thead><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody>');
$.each(data, function(index, value) {
/* some variables for tabledata */
$('#div_testausgabe').append('<tr>');
var text='<td>'+data+'</td><td>'+data+'</td><td>'+data+'</td><td>'+data+'</td><td>'+data+'</td><td>'+data+'</td><td>'+data+'</td>';
$('#div_testausgabe').append(text);
$('#div_testausgabe').append('</tr>');
});
$('#div_testausgabe').append('</tbody></table><hr />');
}
});
});
My problem is that the table doesn't get created correctly. the table tags will surround only the thead part.
/* some variables for tabledata *"probably to/* some variables for tabledata */.append('</tr>');Append() doesn't write string to document but append element. What about reading the DOC?.append()you are supposed to be appending complete DOM nodes.$('#div_testausgabe').append('<tr>');doesn't do what you think. This will append a<tr>tag, not just the opening tag as you think. You need to build the HTML first, then append the whole string..append()is not the same as appending to a string you don't append the opening tag, the data, and then the closing tag. You call.append()with the entire HTML string.