I have the following code where I need to set the "status" variable depending on the success or failure of an ajax call.
function loadPMMLAvailability(algorithmName) {
var status = false;
if (algorithmName) {
$.ajax({
type: "GET",
url: serverUrl + '/api/configs/pmml/' + algorithmName,
success: function (res) {
status = true;
console.log('Im in success');
},
error: function (res) {
status = false;
}
});
}
console.log(status);
return status;
}
In the output I get an "Im in success
" and "false
" which says that status is false. Why isn't it being set to true?