I have a simple function that retrieves a setting from cakephp core using ajax. But returning this value gives back undefined. I have been looking at the code and searching the web on what I am doing wrong, but I still do not seem to see it. It's probably cuz of my long working day that I am overlooking something stupid. Maybe you guys can help me clear up my mind here... What goes wrong is mentioned in the comments of below code:
$(document).ready( function() {
// check session timeout setting from cakephp core
var checkTimeoutSetting = function() {
$.ajax({
url: '/users/checktimeout',
type: "POST",
success: function (data, textStatus, jqXHR) {
// data is logged as 60 on page load
console.log(data);
return data;
}
});
};
var sessiontimeout = checkTimeoutSetting();
console.log('session: '+sessiontimeout);
// sessiontimeout seems undefined now :(
$("#remaining-session-time").html(sessiontimeout);
});
Also tried this with making sessiontimeout
a global variable, but still gives the same undefined
message in my console.log