I'm trying to return a value from one function to another, get_Positions () has to get the lat and lng from parseJson (date), it's just returning undefined. I want to get these two values from within get_Positions ().
get_Positions();
function get_Positions(){
$.ajax({
url: 'http://taxer-cc.umbler.net/read.php',
type: 'POST',
dataType: 'html',
data: 'value1=1'
})
.done(function(data) {
var lct = parseJson(data);
console.log(lct);
})
.fail(function(e) {
console.log("Error: "+e);
});
function parseJson(data){
$.each($.parseJSON(data), function (item, value) {
$.each(value, function (i, k) {
var location = function(){
lat = k.lat;
lng = k.lng;
return [lat,lng];
}
loc = location();
lat = loc[0];
lng = loc[1];
return [lat,lng];
});
});
}
}