Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Contoh Load</title>
- <link rel="stylesheet" href="node_modules/datatables/media/css/jquery.dataTables.min.css" />
- <script src="node_modules/jquery/dist/jquery.min.js"></script>
- <script src="node_modules/datatables/media/js/jquery.dataTables.min.js"></script>
- </head>
- <body>
- <table id="example" class="display" style="width:100%">
- <thead>
- <tr>
- <th>Name</th>
- <th>Image</th>
- </tr>
- </thead>
- </table>
- </body>
- <script>
- $(document).ready(function() {
- $('#example').DataTable( {
- ajax: {
- "url": "data.json",
- "type": "GET"
- },
- columnDefs: [
- {
- targets: 0,
- data: 'nama',
- searchable: false,
- orderable: false
- },
- {
- targets: 1,
- data: 'gambar',
- searchable: false,
- orderable: false,
- render: function (data, type, row, meta) {
- var currentCell = $("#example").DataTable().cells({"row":meta.row, "column":meta.col}).nodes(0);
- $.ajax({
- url: data,
- headers: {
- 'Authorization': "Basic " + btoa("username" + ":" + "password"),
- 'Access-Control-Allow-Origin': '*'
- },
- }).done(function () {
- $(currentCell).append('<img src="' + data + '" />');
- });
- return null;
- },
- },
- ]
- });
- } );
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement