简体   繁体   中英

How to integrate DataTables jQuery plug-in with this setup?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM