Reputation: 392
I have simple code to hide and show paragraph, and using jquery as the trigger
suddenly my jquery return errors,this is the error
SyntaxError: expected expression, got '<'
http://localhost/portofolio1/navigation_test.php/jquery-2.1.3.js
Line 1
ReferenceError: $ is not defined
http://localhost/portofolio1/navigation_test.php/
Line 9
if i use cdn it work perfectly as usual
this is my simple code to test my jquery
<!DOCTYPE html>
<html>
<head>
<title>Simple list</title>
<!-- <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>-->
<script src="jquery-2.1.3.js"></script>
<script>
$(function () {
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<button onclick="">SHOW ALERT</button>
</body>
</html>
SOLVED
after i create new .php file and move ALL the code to the new file, it work normal, i dont know the problem, this sure really weird
Upvotes: 0
Views: 244
Reputation: 119847
Mind the quotes:
<script src="./jquery-2.1.3.js"></script>
type
is optional by the way.
Also check if http://localhost/portofolio1/navigation_test.php/jquery-2.1.3.js
is pointing to jQuery. From the looks of your error, the script is pointing to something not jQuery, possibly an error page, hence SyntaxError: expected expression, got '<'
. This error means that the browser expected a script, but returned HTML (signified by the script meeting an unexpected <
).
Upvotes: 1