Callback gets fired with an alert function is present and it does not fire without an alert?

Callback gets fired with an alert function is present and it does not fire without an alert?

When the alert function is present (shown below), the callback function gets fired and everything works. When the alert function is not present, the callback function never gets fired.

 function getTableData(tableName, startRow, endRow, callback) { CK.getData = $.getJSON("getTableData.php",{tN: tableName, sR: startRow, eR: endRow}, function(dataTable){}); alert("test"); CK.getData.done(function() { // load data inside table using an $.each function... callback(); // works only when the alert function above is present.. }); } getTableData(tableName, startRow, endRow, function() { $(".logTable").after($addRowData); });