I'd like to get true
or false
from $.post by calling abc()
. I found this answer, but I don't get it to work.
Can someone give me a short example with my code?
function abc() {
form = $('form');
formData = form.serialize();
$.post('file.php', formData, function(result) {
form.each(function() {
if (result === this.id) {
return true;
error = true;
}
});
if (error === false) { // no error
return true;
}
});
}
if (abc()) {
// true // <- doesn't work, because $.post is an async function
}