This code snippet gets a Json data from a API hosted in my localhost. I can get the json objects into their own css id(selector?) but I want to use value somewhere else in my javascript. For example, I want to use '#long' in my javascript. I tried using global variable but it says that 'long' is undefined. What do I have to do so that I can use uid, lat or long elsewhere in my script?
$(document).ready(function(){
$.get("http://localhost:4567/get/233307/loc", function(data){
$('#uid').append("UID: " + data.uid);
$('#lat').append("Latitute: " + data.lat);
$('#long').append("Longitude: " + data.long);
var long = data.long;
alert(long);
}, "json");
});
Thanks.