【发布时间】:2019-06-02 17:33:52
【问题描述】:
我正在为我的 FiveM 的服务器网站设置一个“统计”页面,我需要有关如何使用 Jquery Datatables 显示数据的帮助
我对API一无所知,所以我用PHP尝试了一些东西,但没有什么真正有用的:/
这是我的代码:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>test-astos</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
</head>
<body>
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<!-- data -->
</tbody>
</table>
<script type="text/javascript">
$(document).ready( function () {
$('#table_id').DataTable({
$.ajax({
url : 'https://api.top-serveurs.net/v1/servers/SC4VCSEUS3/players-ranking',
type : 'GET',
dataType : 'json',
success : function(json, statut){ // code_html contient le HTML renvoyé
}
});
});
});
</script>
</body>
</html>
我想用 Jquery 数据表显示这些数据 (https://api.top-serveurs.net/v1/servers/SC4VCSEUS3/players-ranking)。
谢谢:)。
【问题讨论】:
标签: jquery ajax api url datatables