I have a function which checks if there is a cookie session via an ajax call before the user adds of edits data the problem is that it takes too long to make the call to return the value in time so instead it always returns: undefined is there a way to run this function so that it will return the data in time? thanks for reading.
function checkSession(){
$.get('/check_session.php',function(data){
if(data == "loggedOut"){
return "lo";
}
}
function doSomething(){ //check if your logged in
if(checkSession() == "lo"){ //always returns:undefined
alert('your have been logged out');
}else{ //do stuff
}
}