我有一个 URL“ http://localhost:8888/api/rest/abc
”,它将提供以下 json 数据。我想使用 Jquery 或 java 脚本在我的 UI 中获取这些数据。我从几个小时开始尝试这个,但我无法解决它。请给我一些解决方案,这将有助于我解决这个问题。
{
"My-user": [
{
"link": [
{
"href": "http://localhost:8888/api/rest/abc/MI/CH",
"rel": "self",
"type": "application/my.My.My-user+xml",
"title": "rln"
},
{
"href": "http://localhost:8888/api/rest/cabin?MI=mi&CH=ch",
"rel": "some relation",
"type": "application/my.My.My-cabin+xml",
"title": "rln1"
}
],
"My-user-list": [
{
"name": "cuba",
"Explanation": "bark"
}
],
"CH": "ch",
"MI": "mi",
"password": "xyz",
},
{
"link": [
{
"href": "http://localhost:8888/api/rest/abc/DD/KN",
"rel": "self",
"type": "application/my.My.My-user+xml",
"title": "rln"
},
{
"href": "http://localhost:8888/api/rest/cabin?DD=dd&KN=kn",
"rel": "some relation",
"type": "application/my.My.My-cabin+xml",
"title": "rln1"
}
],
"My-user-list": [
{
"name": "Cuba1",
"Explanation": "bark1"
}
],
"KN": "kn",
"DD": "dd",
"password": "xyz1",
}
]
}
我已经尝试过 Getjson 这对我来说不起作用这是我的代码如果代码错误请纠正我。
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script>
$.getJSON('/api/rest/abc', function(data) {
console.log(data);
});
</script>
</head>
<body>
</body>
</html>