We want to display all the names from our json file into a div using javascript. We tried a lot of things, but we didn't manage to succeed.
json data : http://www.smartbustracking.be/json/data.json
This is what we tried :
<button>get data</button>
<div id="resultJson"></div>
<script type="text/javascript" language="javascript">
$("button").click(function(){
$.getJSON("http://www.smartbustracking.be/json/data.json", function(result){
for(var x = 0; x < result.length; x++){
$.each(result, function(i, field) {
$("#resultJson").append(field[x].name);
}
}
});
});
If anyone can help us with this ploblem, that would be great
Thanks in advance !