I pass activerecord data from rails to JavaScript function as JSON using ajax. my request.responseText looks like this
[{"site": {"lng": 55.1443, "lat": 25.0608}},
{"site": {"lng": 55.1065, "lat": 25.0399}}]
Below is my JavaScript code
var sites=eval('(' + request.responseText + ')');
for (var i = 0 ; i < sites.length ; i++) {
var site=sites[i].attributes
var lat=site.lat;
var lng=site.lng;
but if I alert(site.lat)
it's returning undefined
. What am I doing wrong here?