<!doctype html> <html> <head> <Meta charset="utf-8"> <title>无标题文档</title> <script src="vendor/jquery-1.7.2.min.js"></script> <script src="jquery.dynatable.js"></script> <link rel="stylesheet" href="jquery.dynatable.css" > </head> <body> <script> $(document).ready(function() { var mytable= $("#dynatable"); setInterval(function() { $.ajax({ url: "do.PHP",success: function(data) { myRecords = $.parseJSON(data); mytable.dynatable({ dataset: { records:myRecords } }); mytable.data('dynatable').settings.dataset.records=myRecords; mytable.data('dynatable').dom.update(); console.log(data); } }); },1000); }); </script> <table id="dynatable"> <thead> <th>test1</th> <th>test2</th> </thead> <tbody> </tbody> </table> </body> </html>
<?PHP $response = array(); $response [] = array( "test1" => "AAAA".time(),"test2" => "BBBB".time() ); echo json_encode($response); ?>
$(document).ready(function() { setInterval(function() { $.ajax({ url: "myStuff.PHP",success: function(data) { console.log(data); var myRecords = $.parseJSON(data); var dynatable = $('#dynatable').dynatable({ dataset: { records: myRecords } }).data('dynatable'); dynatable.settings.dataset.originalRecords = myRecords; dynatable.process(); } }); },3000); });原文链接:https://www.f2er.com/ajax/164099.html