I have this error on a simple jsp : Uncaught ReferenceError: $ is not defined
I've just try to recall a service rest on another project on eclipse but it seem doesn't work..
Code is here :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script rel="javascript" type="text/javascript" href="js/jquery-1.11.3.min.js" />
</head>
<body>
<script>
var people = {
"address": "Street 12",
"name": "twelve",
"id": 12,
"surname": "twelve"
};
function sendobject() {
$.ajax({
type: "POST",
url: "http://localhost:8080/HibernateTutorialWeb/rest/person/post",
data: markers,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert(data);
},
failure: function(errMsg) {
alert(errMsg);
}
});
}
</script>
<input type="button" onclick="sendobject()" value="send"> </input>
</body>
</<html>
Update:
Tried using the jQuery from Google CDN, but still doesn't work
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
Uncaught ReferenceError: $ is not defined sendobject @ index.jsp:15onclick @ index.jsp:28
This question is not a duplicate of Uncaught ReferenceError: $ is not defined?
Because all the answer of that question suggest to put the references to the jquery scripts first, but it does not work for me .
The right solution was given in tushar's answer
So it's a similar question with a different problem and different solution.
<script>
should not be self-closed, it'll not load the script. See Why don't self-closing script tags work?
Change
<script rel="javascript" type="text/javascript" href="js/jquery-1.11.3.min.js"/>
to
<script rel="javascript" type="text/javascript" href="js/jquery-1.11.3.min.js"></script>
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