This should be really simple but it's after 2am and I'm struggling!
So I have a PHP file that outputs a database query in JSON format. The plan is then to use Columns (https://github.com/eisenbraun/columns) to format this JSON into a simple table.
The page has a box with a value, when clicking on this value, I want to use AJAX to get the result from my PHP script and display a table.
Currently, I have the table loading at the same time as the page;
<script>
$(document).ready(function(){
var json1 = <?php include($inc.'xx\sp1.php');?>;
$('#sp1').columns({data:json1});
var json2 = <?php include($inc.'xx\sp2.php');?>;
$('#sp2').columns({data:json2});
});
</script>
with the links on the value being;
<a class='btn btn-secondary' data-toggle="modal" href="#sp1">
<a class='btn btn-secondary' data-toggle="modal" href="#sp2">
How can I set the variables (Json1 & Json2) and load the data via an AJAX on click event? I know it's staring me in the face and it's hugely frustrating!