How to make below function to return true if success, otherwise false. I have make return on it but the result is 'undefined' when i call it to other javascript on the same page like **if(onloadCallback == false)
**. Thank you for helping.
<script type="text/javascript">
var onloadCallback = function () {
grecaptcha.render('dvCaptcha', {
'sitekey': '<%= ReCaptcha_Key %>',
'callback': function (response) {
$.ajax({
type: "POST",
url: "product-info.aspx/VerifyCaptcha",
data: "{response: '" + response + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var captchaResponse = jQuery.parseJSON(r.d);
if (captchaResponse.success) {
$("[id*=txtCaptcha]").val(captchaResponse.success);
$("[id*=rfvCaptcha]").hide();
return true;
} else {
$("[id*=txtCaptcha]").val("");
$("[id*=rfvCaptcha]").show();
var error = captchaResponse["error-codes"][0];
$("[id*=rfvCaptcha]").html("ReCaptcha error. " + error);
return false;
}
}
});
}
});
};
</script>