[jQuery] ajax post request in custom method?
Hi,
I've made a custom method with addMethod to check a captcha.
Basically, the captcha image is made in php and its value is sent to a
session variable. So I make an AJAX post request to a php page which
checks the input's value against that session variable.
verify: function(value, element) {
$.post("scripts/verification-check.php", {inputString: value},
function(data){
//data will be equal to true or false if the input's value is
equal to the session variable
return data;
});
},
My problem is that the error shows up before the AJAX request is
finished...I think. 'Cause the way I have it now, no matter what, the
error label always shows up - even if 'data' is true.
So, is there a way to 'delay' the event that inserts the error label
until the AJAX call is finished?
Thanks :)