Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

js: Uncaught ReferenceError: xxx is not defined



  • I try to run some simple sample code that use webengine to load html file and run js function embeded in html file. But the console show that js: Uncaught ReferenceError: xxx is not defined. xxx is js function.



  • 669999e5-f240-4d92-9535-97876ca93c46-image.png
    2e41cb77-0ef9-4c9d-aaf5-65a15b9e34bd-image.png
    7226b8c1-094b-4073-bdab-fa55c82eefc2-image.png



  • There is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this 'x' is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the 'x'.

    To solve this error: Load your library at the beginning of all your scripts.

    There can be multiple other reasons for this issue:

    • Added JavaScript library after the script were you see that error
    • Conflict with Other JavaScript Libraries
    • Path to JavaScript library you included is not correct
    • The jQuery library file is corrupted
    • May be a chance where you are working offline

Log in to reply