I´m creating frontend for app and i need to call api function. I've got a url from api, which gives me json data like this:
{ "id": 1, "name": "First Like", "description": "Like at least 1", "image": "images/badges/FIRST_LIKE" }
I need to call some of those items in my website.
<script type="text/javascript">
//url to call http://eclipsewildflyserver-gobanit.com/rest/something/id=1
function getList(){
var name = url.getItem("description");
document.getElementById("name").innerHTML = name.toString();
}
I know im doing this completely wrong, and its my first atempt to do something like this, so I would really apreciate the help. Where should and how should I add url to code so i can pick a items i need? Thanks
EDIT: So i tried to replace with the ideas you gave me, and its still not working. Can anyone tell me what am I doing wrong?
<script type = "texxt/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" language="javascript">
<head>
$.getJSON('http://eclipsewildflyserver-gobanit.rhcloud.com/AssignToolWebApp/rest/id=1', function (data) {
var name = data;
document.getElementById("name").innerHTML = name.toString();
});
</script>
</head>
<body onload=getList()>
<div id="TopHeader">
<div id="header" class="container">
<div id="menu">
<ul>
<h1 id="name"></h1>
</ul>
</div>
</div>
</div>
</body></html>
Just trying to write a JSON string to page. Not working. I guess I´m doing something wrong.