Reputation: 345
I am getting the following error:
Uncaught TypeError: undefined is not a function Hello.html:30createSite Hello.html:30(anonymous function) Hello.html:22j jquery-latest.min.js:2k.fireWith jquery-latest.min.js:2m.extend.ready jquery-latest.min.js:2J
Below is my code:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Hello</h1>
<script>
$(function() {
var Site = {
id: 3,
name: "JSON test Site",
latitude: 12.23,
longitude: 23.34
};
createSite(Site);
});
function createSite(Site) {
$.ajax({
url : "api/site",
type : "post",
data: JSON.Stringify(Site),
dataType: "json",
contentype: "application/json",
success: function(response) {
console.log(response);
},
error: function(response) {
console.log(response);
}
});
}
</script>
</body>
</html>
Any ideas?
Upvotes: 0
Views: 93
Reputation: 8590
Javascript is case sensitive JSON.Stringify(Site)
should be JSON.stringify(Site)
(lowercase "s")
Upvotes: 1