I am retrieving response value from an ajax GET. I am trying to return the value using a callback function but its not returning the value. BUt when I output it to the console.log the value is shown.
Can anyone please help me return the value?
Any help would be really appreciated!!
This is not a duplicate because I am using a CALLBACK as opposed to the other question where there was no CALLBACK being used
// First Return the current logged hours when user wants to update the logged hours
$(document).on("click",".update_logged_hrs", function () {
var cur_task_hrs = getLatestCatHrs(cat_id, function (hrs) {
return hrs; // Not returning
});
console.log(cur_task_hrs)//Returns undefined
}):
//Call back function goes here
function getLatestCatHrs(cat_id,callback){
$.get("<?=base_url().ProjCollabNavLinks::$proj_todos?>",{
latest_logged_cat_hrs : true,
cat_id : cat_id
})
.done(function (res) {
callback(res);
});
}