I have written a program to create a json object from the list of values obtained from database and here is how my json looks
{
1: {
age: "21",
name: "arjun",
gender: "male"
},
2: {
age: "30",
name: "ravi",
gender: "male"
},
3: {
age: "57",
name: "pushpa",
gender: "female"
}
}
Now i want to parse it using jquery and print the result in tabular form in html. I have tried to some extent , but not understanding what to do further, so please need some guidance
My json_parse.js :
$(document).ready(function() {
var url = "http://182.168.1.115:8082/JqueryForm/userdetails_json.jsp"
$.parseJSON(url, function(json) {
var tr;
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].name + "</td>");
tr.append("<td>" + json[i].age + "</td>");
tr.append("<td>" + json[i].gender + "</td>");
$("#table").append(tr);
}
});
});
My list_user.html:
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script src="json_parse.js"></script>
</head>
<body>
<table name="Table" id="table">
</table>
</div>
</body>
</html>