的index.php
<table id="example" class="table table-striped table-bordered dt-responsive nowrap"
cellspacing="0" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Symbol</th>
<th>Price USD</th>
<th>Price BTC</th>
<th>24h Volume USD</th>
<th>Market Cap USD</th>
</tr>
</thead>
<tbody id="dsff">
</tbody>
</table>
function makeTimer() { jQuery.ajax({ url: "ajax.php", data: { abc: 1}, type: "POST",
success:function(data){ $("#dsff").html(data); }, error:function (){} }); } setInterval(function()
{ makeTimer(); }, 1000); ajax.php
<?php
if(isset($_POST['abc'])){
?>
<tr>
<td>1</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
</tr>
<tr>
<td>1</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
</tr>
<tr>
<td>1</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
</tr>
<tr>
<td>1</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
</tr>
<tr>
<td>1</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
<td>fdfdgfdg</a>
</td>
</tr>
<?php } ?>
我正在自动刷新表格,但它正在刷新整个表格。
例如:
我试过这段代码,但对我不起作用:
var table = $('#example').DataTable( {
ajax: "data.json"
});
setInterval( function () {
table.ajax.reload();
}, 30000);
问题:任何人都可以解决此问题吗?