I have function to get id of calculation from db
Here is code:
function getClaculationId() {
    var appointmentid = parseInt($('#appointmentId').text());
    var model = {
        appointmentId:appointmentid
    }
    $.ajax({
        url: '@Url.Action("GetCalculationId","Calculations")',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(model),
        type: 'POST',
        dataType: 'json',
        processData: false,
        success: function(data) {
            var list = data;
           $("#calculationId").text(list[0].calcId);
        }
    });
}
After this I need to get this id and use in another function
Here is code of this function
function getConsumables() {
   var calculationId = $('#calculationId').text();
   var model = {
       calcId: parseInt(calculationId)
   };
   $.ajax({
       url: '@Url.Action("GetConsumables", "Calculations")',
       contentType: 'application/json; charset=utf-8',
       data: JSON.stringify(model),
       type: 'POST',
       dataType: 'json',
       processData: false,
       success: function(data) {
           var list = data;
           for (var i = 0; i <= list.length - 1; i++) {
               var calculationTable = '<td class="point">' +
                   (i + 1) +
                   '</td>' +
                   '<td class="title"> ' +
                   list[i].consumableName +
                   '</td>' +
                   '<td class="title"> ' +
                   list[i].quantity +
                   '</td>' +
                   '<td class="title"> ' +
                   list[i].description +
                   '</td>' +
                   '<td class="title"> ' +
                   '</td>' +
                   '<td class="title"> ' +
                   list[i].summ +
                   '</td>';
               $('#consumables').append(calculationTable);
           };
       }
   });
}
And I calling those function like this
$('#calculate').click(function() {
    $('#main-info').load('@Url.Action("Calculations","PatientDatabase")',function() {
        getClaculationId();
        getConsumables();
    });
});
But problem in that when getConsumables() runs, calculationId is empty.
How I need to write code correctly to pass calculationId to second function?
Thank's for help.
 
     
     
    