I’m using jQuery to read a JSON file containing a simple array of numbers, as such:
({
"values": [
{
"12",
"32",
"21",
"23",
"34"
"43",
"52",
"86",
"25"
}
]})
My JS (as follows) keeps returning “undefined”. Can someone please help?
$('#dataviewer').live('pageshow', function () {
$.getJSON("test.json", "chartData");
$(function chartData(data) {
var chartString = "";
$.each(data, function(index){
chartString += index.values;
});
alert('chartString' + chartString);
});
});
There’s a lot wrong with your javascript, it should be more like this:
Also, json is obviously invalid, as has been stated in many other answers.