mercredi 11 mars 2015

Loading JSON with jQuery, then displaying to the viewer


Vote count:

0




im trying to load a Json file via URL http://ift.tt/1wux3zy...


What I need it to do is display a list of locations.


Here is an example of the JSON code



{
"Locations":{
"Location":[{
"elevation":"228.0",
"id":"3063","latitude":"57.206",
"longitude":"-3.827",
"name":"Aviemore",
"nationalPark":"Cairngorms National Park",
"region":"he",
"unitaryAuthArea":"Highland"
},
{
"elevation":"1245.0",
"id":"3065",
"latitude":"57.116",
"longitude":"-3.642",
"name":"Cairn Gorm Summit",
"nationalPark":"Cairngorms National Park",
"region":"he",
"unitaryAuthArea":"Moray"
},{
"elevation":"146.0",
"id":"3238",
"latitude":"55.02",
"longitude":"-1.88",
"name":"Albemarle",
"region":"ne",
"unitaryAuthArea":"Northumberland"
}]}}


SO far I have tried ...



<script type="text/javascript">

$(document).ready(function() {
$("#driver").click(function(event){


$.getJSON('http://ift.tt/1HDaZ7c', function(jd) { $('#stage').html('


locations: ' + jd.locations + '


'); $('#stage').append('

location: ' + jd.location+ '


'); $('#stage').append('

name: ' + jd.name+ '


'); }); }); });

It fails to load every time, I've followed many tutorials, all of which seem to have been no help.


Thanks.



asked 29 secs ago







Loading JSON with jQuery, then displaying to the viewer

Aucun commentaire:

Enregistrer un commentaire