I'm struggling to grasp how callbacks function within my code. My current task involves creating a function that validates user input and includes an HTTP GET call to the API for additional checking.
The issue lies in the fact that the validate function is being called from the process function, and the submit function executes before the HTTP call in validate(). Unfortunately, I can't modify the process function as it's utilized by other components.
form.process = function(){
// do stuffs
validate();
submit();
}
form.validate = function () {
// lots of checks regarding the model
...
// HTTP GET call
}
Is there a way to make the submit function wait until the HTTP GET call in validate() is complete?
Appreciate any insights :)