Function Not Defined in JavaScript (How to Fix It) - Maker's Aid
The Function Isn’t Defined at All The most obvious—and, ironically, the most common—cause for the function not defined error is that, no prizes for guessing, the function isn’t defined in your code at all. To save yourself hours of chasing a red herring, this is also the first probable cause you should rule out when debugging your code.