I have a HTML div that is fed a JSON output formatted as a HTML table when a function is called:
<div id="content"></div>
JS:
$.ajax({
url: "script.php",
type: "POST",
dataType:'json',
data: dataString,
cache: false,
success: function(data){
var htmlStr = '';
htmlStr += '<table id="summary-table">'
... // appends table content to htmlStr
$("#content").html(htmlStr);
}
})
After setting the content, then call datatables on the table in question:
$("#content").html(htmlStr);
$('#summary-table').dataTable({...});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.