I would like to write the following variable in the HTML code through JavaScript.
{
"content": "Hallo Welt, das ist ein Testn",
"filelength": 1,
"filename": "a5c12c102bdaed8ee80168cb41606295eaf5512ba04045fac5dd0dc65c2f54f13566090025c05f14cdfdf9b1e39ce835c6f3262a4aedba31f8b6d07ed299b23b",
"language": "plain",
"path": "caadaf7ed1f27ea37cbb9157d9c6cff1683cae85244b772c856b660c3609ad32faa0d6997ecaf727c46650443f1a03f63c0f67219f46d10cf5295556579422b6/c6ee9e33cf5c6715a1d148fd73f7318884b41adcb916021e2bc0e800a5c5dd97f5142178f6ae88c8fdd98e1afb0ce4c8d2c54b5f37b30b7da1997bb33b0b8a31/a5c12c102bdaed8ee80168cb41606295eaf5512ba04045fac5dd0dc65c2f54f13566090025c05f14cdfdf9b1e39ce835c6f3262a4aedba31f8b6d07ed299b23b",
"type": "text"
}
The problem is, when I look at the HTMl code in the browser, it doesn’t show the corresponding variable, it shows
[object Object]
here the code to extend the HTML code
// create the row
let row = "<tr>";
// set the actions
let actions_append = '';
// file
if (value['type'] === 'file') {
// preview
if (value['preview_available']) {
console.log(value["preview"]);
actions_append += `<td nowrap width="1%">
<span data-toggle="tooltip" title="Vorschau" onclick="setPreviewContent(${value['preview']})">
<button onclick="setNames('${value['name']}')" type="button" class="btn btn-link btn-sm"
data-toggle="modal" data-target="#previewModal"><i class="material-icons text-primary">desktop_windows</i>
</button>
</span>
</td>`
}
}
// append row to table
$('#fileTableBody').append(row + actions_append + '</tr>')
here the HTML code resulting output
<td width="1%" nowrap="">
<span data-toggle="tooltip" title="Vorschau" onclick="setPreviewContent('[object Object]')">
<button onclick="setNames('test.txt')" type="button" class="btn btn-link btn-sm"
data-toggle="modal" data-target="#previewModal"><i class="material-icons text-primary">desktop_windows</i>
</button>
</span>
</td>
Can anybody help me? I don’t know JavaScript so well.