[Answer]-Wait until another ajax return the response

1👍

It’s javascript – use callbacks!

getepoc(historyItem[i].timestarted, function(time) {
    console.log(time);
    htmlData +=
        "<tr><td>"+historyItem[i].topicname+"</td>"+                                   
            "<td>"+historyItem[i].status+"</td>"+
            "<td>"+time+"</td>"+
            "<td>"+timetaken+"</td>"+
        "</tr>";
});

function getepoc(epochtime, callback) {
    $.ajax({
        beforeSend: before_send_csrf,
        url : CHANGE_TO_EPOCH_TIME,

        type : "POST",
        cache : false,

        dataType: "json",
        data: "etime="+epochtime,
        success: function(data) {
            alert('converted '+ data);
            callback(data);      
    }
    });
}

Leave a comment