I have been searching the solution to my problem for four days, and I still can't solve it.
I want to convert a JSON string data (from an URL) into a dynamic table, using JQuery and JavaScript.
I have to load the JSON string using the jQuery.getJSON() function.
I don't know how to combine those two things together.
I've been searching for forever and I still don't understand it. Sorry if I sound really stupid but I just can't make something out of it. Can someone please help me?
This is my code:
<html>
<head>
<h1> Inventory List </h1>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://wt.ops.few.vu.nl/api/--------"></script>
</head>
<body>
<script>
$(document).ready(function () {
$.getJSON(http://wt.ops.few.vu.nl/api/-------,
function (json) {
var tr;
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].category + "</td>");
tr.append("<td>" + json[i].name + "</td>");
tr.append("<td>" + json[i].amount + "</td>");
tr.append("<td>" + json[i].location + "</td>");
tr.append("<td>" + json[i].date + "</td>");
$('#table').append(tr);
}
});
});
</script>
<table id= "table">
<tr>
<th> Name of product</th>
<th> Category</th>
<th> Amount</th>
<th> Location</th>
<th> Date</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
.getJSON('http://wt.ops.few.vu.nl/api/--------', function(json){});Must wrap URL quotes.