I have a DataTables table that loads data from
$table.dataTable({
ajax: 'path/to/getData.php',
});
getData.php makes some database calls and returns json_encode() of the output array and DataTables is able to parse it just fine.
However if someone was to go to http://mywebsite.com/path/to/getData.php, they would be able to see all of the raw JSON data and potentially scrape it.
Is there a way to prevent people from accessing getData.php unless it is called by dataTables?
I'm fairly certain this will have to be a modification to the PHP code since anyone could potentially see my workaround via Javascript.
<html>table's contents, and remove theajaxoption from your DataTable definition. There are probably several different ways to do this - but here is one. See also HTML (DOM) sourced data. The end user will only have access to one page of data at a time - and will need to scrape it from the HTML instead of getting it all from a JSON response.