<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<script src="jquery.js"></script>
<script type="text/javascript">
var index = "index";
var park = "park";
$(document).ready(function() {
$("button").click(function() {
url="http://openAPI.seoul.go.kr:8088/personalKeyvalue/json/SearchParkInfoService/1/3"
$.getJSON(url,function(result) {
JSONObject jsonRoot = new JSONObject(result);
JSONObject jsonService = jsonRoot.getJSONObject("SearchParkInfoService");
int totalCount = jsonService.getInt("list_total_count");
JSONArray json = jsonService.getJSONArray("row");
for (var i = 0; i < totalCount; i++) {
document.write(json+"<br>");
}
});
});
});
</script>
</head>
<body>
<h2>Retrieve data from JSON with AJAX!</h2>
<button>GetAJAX data</button>
</body>
</html>
我有Uncaught SyntaxError: Unexpected identifier
谷歌浏览器。
错误发生在第 14 行,即:
JSONObject jsonRoot = new JSONObject(result);
你能提供任何解决问题的建议吗?