I have this code to query my server:
function myAjaxCheck(token) {
$.ajax({
type: 'POST',
url: 'auth.php',
data: {
token: token,
},
dataType: 'json',
success: function (data) {
if (data.auth == 'OK') {
alert ('ok');
}
} else {
alert('Error: ' + data.auth);
}
}
}).done(function (data) {
return data;
});
}
So, I need to pass the returned data to a type variable:
Var MyVariable = myAjaxCheck(token);
console.log(MyVariable);
on the console:
undefined
Where is the problem, it is assumed that the data will be returned when it is done, but it is not.
source
share