So this is how you can do it:
This link will show you how to manipulate more in detail: http://jsfiddle.net/9zfHE/8/
$(document).ready(function(){
$("#button").click(function(){
$.getJSON("http://example.com/",function(result){
$.each(result, function(i, field){
$("#myDiv").append("<tr id='bord'><td>"+i + "</td><td> " + field.name + "</td><td>" + field.description + "</td></tr>");
});
});
});
});
This link is exactly what you want as per it looks: http://jsfiddle.net/9zfHE/10/
$(document).ready(function(){
$("#button").click(function(){
$.getJSON("http://example.com/",function(result){
$.each(result, function(i, field){
$("#myDiv").append("<h4>" + field.name + "</h4><p>" + field.description + "</p>");
});
});
});
});
You have to use ajax & .getJSON method which basically grabs fields from a url. Then I appended a table grabbing data from your json to the div.
If you add more data to your json then you can grab it by field.[json-field-name] and also give any style you like by providing 'id' to it & then styling in css. i keeps track of the number of elements in the json file.
Hope this helps
More documentation on: http://api.jquery.com/jquery.getjson/
Ajax uses a jquery plugin which needs to be embedded in your page for the .getJSON method to work.
[EDIT:] This is how your html file looks like:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#button").click(function(){
$.getJSON("http://example.com/",function(result){
$.each(result, function(i, field){
$("#myDiv").append("<h4>" + field.name + "</h4><p>" + field.description + "</p>");
});
});
});
});
</script>
</head>
<body>
<div id="myDiv"><h2>Click Button to display information!</h2></div>
<input type="submit" id="button" value="Change Content"></input>
<div></div>
</body>
</html>