Chalupabatman
Programmer
Hi - I am declaring the variable table but when my page loads I am getting the error: Uncaught TypeError: Cannot read property 'row' of undefined
How should I change my code so this functions as desired?
How should I change my code so this functions as desired?
Code:
<script>
var table;
$(document).ready(function () {
$("#btnTapCountCheck").click(function () {
table = $('#data').DataTable({
dom: 'Bfrtip',
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ],
"ajax": function (data, callback, settings) {
$.ajax({
url: '[URL unfurl="true"]https://localhost:44328/api/tap-count',[/URL]
dataType: "JSON",
success: function (data) {
var o = {"data":[]};
for(var i in data.data)
{
var row = [data.data[i].location,data.data[i].tapCount];
o.data.push(row);
}
callback(o);
}
})
}
}
});
$("#AddRow").click(function () {
table.row.add( [] ).draw(false);
} );
$('#AddRow').click();
});
});
</script>