I do an ajax call:
$.ajax({
url: '/foo/getData',
dataType: 'json',
async: false,
success: function(data){
lat = data.project_x;
lng = data.project_y;
zoomin = parseInt(data.mapzoom);
console.log(data);
}
});
and return:
[{"id":"3","project_x":"42.456","project_y":"-70.123","zoom":"7"},{"id":"3","project_x":"41.123","project_y":"-71.456","zoom":"7"}]
console.log(data) gives me:
Object
id: "3"
project_x: "42.456"
project_y: "-70.123"
Yet when I try to assign these values to something I get undefined. Example:
console.log(data.project_x);
returns undefined when I would expect it to return 42.456
What am I doing wrong here?