Google Developer Tools is displaying the following error when my PHP page uses the content from a javascript file (my_scripts.js):
"Uncaught ReferenceError: $ is not defined scripts.js:1 (anonymous function)"
Content of my_scripts.js
$('a.button').click(function(){
window.location.href = "another_page.php";
});
The page and the script work as required. Clicking the element links to the requested page, but the error is there.
1) What causes the error? 2) Can it or should it be ignored?
1) It looks like your problem is that jQuery haven't been loaded.
Make sure you load jQuery before scripts.js
.
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
2) Errors should never be ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With