I use $.getJSON to retrieve json file, such as purchase.json, and dynamically create a table through processJSON(data), a function to create table dynamically with JSON content. The table id is "example". Next I need to apply dataTable, a jQuery plug-in, to this table so I can apply pagination and other features to the table. The JavaScript I have is -
$(document).ready(function() {
$('#AJAXButton').click(function() {
$.getJSON('data/purchase.json', function(data) {
processJSON(data);
});
});
});
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"bPaginate": false
} );
} );
I was able to create the table with JSON content, but dataTable features were not working. How to adjust my code to make it work?
Thanks for helping me out. C. L.