我收到以下错误:
Uncaught TypeError:undefined不是函数Hello.html:30createSite Hello.html:30(匿名函数)Hello.html:22j jquery-latest.min.js:2k.fireWith jquery-latest.min.js:2m .extend.ready jquery-latest.min.js:2J
以下是我的代码:
<!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>
有什么想法吗?
答案 0 :(得分:1)
Javascript区分大小写JSON.Stringify(Site)
应为JSON.stringify(Site)
(小写&#34; s&#34;)