I'm trying to validate a field by making an ajax call. However because it is an async call it is always returning false. Ive tried to add a timeout but still no luck. Am I doing something wrong? I also tried it using a simple check to see if the ajax call was the issue and it worked fine.
$.validator.addMethod("validateSupplierCode" + currTabExt, function (value, element, params) {
var result = false;
callAjax('Supplier/ValidateSupplier?Code=' + value, 'GET', "", function success(data) {
if (data.isValid) {
console.log("trueee");
result = true;
} else {
console.log("falsseeeee");
result = false;
}
});
setTimeout(function () {
return result;
}, 100);
}, "Please enter a valid supplier or 'MISC'");