As someone who is new to programming, I primarily use Python but have now encountered a situation where I need to work with JavaScript for a project utilizing Phonegap.
The query retrieved from the server looks like this:
[["CompanyName", "lat", "long", ID, "street", 6.8], ["CompanyName", "lat", "long", ID, "street", 23.7]]
In Python, I would do the following to print the CompanyName for each entry:
for x in r.json():
print x[0]
How can I achieve the same outcome using JavaScript?
When attempting to loop through the query data in JavaScript, it iterates over each character of the string. To address this, I tried the following:
var result = xmlhttp.responseText;
result = eval("("+ result +")");
To iterate through the data, I used:
for (var i in result)
{
display +="<br/>" + result[i];}
Is there a way to target only the CompanyName, similar to what was done in the Python code above?
`