Modify the following code I have added action in it.
$('#btnDoCalculation').click(function(e){
var formData = $('#interest_calculator').serialize();
$.ajax({
type: 'POST',
url: '<?php echo admin_url('admin-ajax.php');?>',
data:formData,
dataType: 'json',
action:calculate_investor_interest
encode:true,
}).done(function(data){
if(data.success){
console.log(data);
var results = data.calc_results;
var newData = results.reduce(function(collection, element){
var rowData = {}; //create a new empty row
element.reduce(function(collection, element){
//put the elements into the row
rowData[element[0]] = element[1];
return rowData;
}, rowData);
collection.push(rowData); //add the row to the results
return collection;
}, []);
var tr;
//overwrite data
$('#compound_interest_table tbody').empty();
for (var i=0; i<newData.length; i++){
tr = $('<tr/>');
//put datejs library here.....
tr.append('<td>' + newData[i].maturity_date + '</td>' );
tr.append('<td>' + newData[i].interest_rate + '</td>' );
tr.append('<td class="hidden-xs hidden-sm">' + newData[i].interest_earned + '</td>' );
tr.append('<td>' + newData[i].management_fee + '</td>' );
tr.append('<td class="hidden-xs hidden-sm">' + newData[i].gross_earning + '</td>' );
tr.append('<td class="hidden-xs hidden-sm">' + newData[i].investor_net_commission + '</td>' );
tr.append('<td>' + newData[i].investor_net_earning + '</td>' );
$('#compound_interest_table tbody').append(tr);
}
});
e.preventDefault();
});