I have an form loaded by AJAX, and inside that form I have render the reCaptcha control. When I post the form, first I validate, and that use my webservice to validate the captcha. If it all data is right I want to post the form.
But the last behavior don't append...
I read this posts:
- Can't submit after preventDefault
- How to reenable event.preventDefault?
- Re-enabling Submit after prevent default
- jQuery: call the action's form after calling preventDefault()
But none of the solutions work... :(
My code:
$('#myForm').submit(function (e) {
e.preventDefault();
var captchaInfo = {
challengeValue: Recaptcha.get_challenge(),
responseValue: Recaptcha.get_response(),
};
$.ajax({
type: 'POST',
url: '@Url.Action("ValidateCaptcha")',
data: JSON.stringify(captchaInfo),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
if (msg) {
$('#myForm').submit();
}
else {
helpers.setCaptcha("captcha");
}
},
error: function (req, status, error) {
alert("error: " + error);
helpers.setCaptcha("captcha");
},
});
});
How I resolve this?
Thanks in advance