Getting 422 (Unprocessable Entity) error when loading custom JavaScript

sdtriathlete
Community Member

I added a custom JavaScript function via the 'custom JavaScript' file upload in the Theme Editor and it adds it fine there, but when it loads a page in Canvas it doesn't load my custom JavaScript but shows an error in the console: ERR_ABORTED 422 (Unprocessable Entity). It seems to load custom CSS just fine. When I copy the link text and paste it into another browser window I see this:

<!DOCTYPE html> <html class="scripts-not-loaded" dir="ltr"   lang="en"> <head>   <meta charset="utf-8">   <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>   <link href="https

That's it. What could be the problem?

The JavaScript I added is essentially a basic test just waiting for document.ready and then showing a simple alert when the user clicks an element...again...not real code yet...just testing capability for a future project that will rely on this custom JS working:

$(document).ready(function () {
   $('.my.class').addEventListener("click", function() {
      alert("Hello World");
   });
});
0 Likes