Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(