I am using an AJAX request to check if something is true or false. Here is the full function including the AJAX request:
function selectAnswer(id, questionId) {
$.get("php/forms/select-answer-process.php?scope=get&id="+questionId, function(data) { if (data == "true") { alert("You can only select one answer per question"); } });
var confirmChoice = confirm("Are you sure you want to select this as the correct answer? This cannot be undone.");
if (confirmChoice) {
$.get("php/forms/select-answer-process.php?scope=save&id="+id);
document.getElementById("answer-check-"+id).src = "img/icons/check-green.png";
} else {
return false;
}
}
The alert works great, but I want to exit the parent function if the AJAX response is true. How can I do that?