0
The last line of the code below is the first to be executed, and I need the function containing this ajax to return true or false, but when I put to return inside Success,error or complete it does not work.
error: function (response) {
if (((response.responseText.split("{")[1]).split("}")[0]).split(":")[1]) {
confirmationValue = true;
} else {
confirmationValue = false;
}
},
complete: function () {
console.log(confirmationValue);
return confirmationValue;
}
});
console.log(confirmationValue);
Thank you!
Ajax, as the name itself says is asynchronous, so Return will make no sense. You can try using async/await, example click here
– N. Dias