I have a form, and before it submits I want to check some of the input against a database. The idea: 1) submit form, 2) check values, 3) show error or actually submit the form. Example:
$(form).submit(function() {
$.post('check.php', {
values
}, function(res) {
// result I need before submitting form or showing an error
});
return false;
});
Now, it takes some time before I get the result (i.e. not instantly), so I put in the return false
at the bottom, preventing the form to submit before I get the $.post results back and do something with it.
Problem: after I get the results from $.post, and everything turns out to be OK, how do I tell the script to go on with submitting the form? If I use submit()
it'll just take it back to this check script, creating an endless loop.
Any ideas? Thanks in advance and Merry Christmas!