Javascript array from JSON not working -


i quite don't understand what's going on here, due lack of knowledge in json.

i have php script returning json ajax query (with datatype:'json'). here end in javascript :

 alert(json.stringify(data.polylines[i])); 

i guess data.polylines[i] object need json.stringify() function show properly. alert shows :

 [["40.632099151611","8.2907695770263"],["57.774700164794","11.870400428772"]] 

which array need variable path in following script (drawing line in google maps api):

map.drawpolyline({      path: path,      strokecolor: '#131540',      strokeopacity: 0.6,      strokeweight: 6 }); 

when :

 var path = data.polylines[i];  map.drawpolyline({      path: path,      strokecolor: '#131540',      strokeopacity: 0.6,      strokeweight: 6 }); 

... it's not working, when :

var path = [["40.632099151611","8.2907695770263"],["57.774700164794","11.870400428772"]];  map.drawpolyline({      path: path,      strokecolor: '#131540',      strokeopacity: 0.6,      strokeweight: 6 }); 

it works. can't figure out why 1 works , not other one, 'alert' test shows same value...

sorry, mistake in loop condition pointed out @pointy. it's working now.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -