Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Datatables server side - get data


I am using this documentation as a sample reference -> https://preview.keenthemes.com/html/metronic/docs/general/datatables/server-side

My datatables is loading continuously without showing results. I suspect I wrongly code the followings in datatables.php:

public function getJsonDecode(): mixed
{
return json_decode(file_get_contents('apps/map/v2/data_fetch.php'), true);
}

my json data is in apps/map/v2/data_fetch.php coded as follows:

<?php
/* Connection to Database */
include('../connection/config.php');
$select_stmt = $dbh->prepare("SELECT * FROM tbl_map LIMIT 100");
$select_stmt->execute();
$row = $select_stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($row, JSON_UNESCAPED_UNICODE)
?>

Seeking help on what did I do wrong?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

Sorry for the late reply.

Have you debugged your server-side code and checked its output? By right your response should follow the Datatable server-side response structure as explained in the plugin's official docs here.

Here you can check the server-side response structure requirements that you will need to follow in order to render the datatable records properly when you receive the server-side data.

Can you please provide a test URL to your page so we can check your backend script response for the database data source query?

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(