我正在使用 AJAX 请求来检查某事是真还是假。这是包括 AJAX 请求的完整功能:
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;
}
}
警报效果很好,但如果 AJAX 响应为真,我想退出父函数。我怎样才能做到这一点?