iterating through json in javascript -


i have iteration trough json cannot make work.

$.post('getdatafromdatabase.php', function(data) {     var output="<ul> start ";      (var in data.results) {         output+="<li>" + data.results[i].id + " " + data.results[i].latitude + "--" + data.results[i].longitude+"</li>";     }      output+=" end </ul>" + data;     document.getelementbyid("bounds").innerhtml += output; }); 

the "start" , "end" print. after "end" printing "data" out works, know getting data database , looks this:

{"results":[{"id":"1","latitude":"47.49882200000000","longitude":"19.05680300000000"},     {"id":"2","latitude":"47.49273300000000","longitude":"19.03345700000000"},{"id":"3","latitude":"47.47765200000000","longitude":"18.98942600000000"},{"id":"4","latitude":"47.47266300000000","longitude":"18.81643700000000"}]} 

can please me this. spent lot of time on , can't figure out why can't print. thanks.

use

var data = $.parsejson(data); 

before start looping read.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -