I'm receiving Uncaught TypeError: success is not a function
at the following code snippet:
waitFor(document.getElementsByClassName('class'), validate);
function waitFor(element, success) {
if (element == null || element.length == 0) {
setTimeout(function() { waitFor(element); }, 100);
} else {
success(element);
}
}
function validate(element) {
//do stuff
}
And my question is why am I receiving this error? validate function is properly defined below. I'm passing it as parameter of waitFor function and than success is undefined inside waitFor. I was passing function as parameter in javascript per this answer: https://stackoverflow.com/a/13286241/5449709
What am I missing?