JQuery parsing Json file size is undefined
I am parsing Json file with JQuery, I got great help from here how to
convert .each loop to for loop and the loop itself works, I have other
problem, the data.lenght is always undefined and the code does not goes to
loop:
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$.getJSON('db.json', function(data)
{
var items = [];
var i, val;
console.log(data); //is full and ok
console.log(data.length); //problem here
for (i=0; i< data.length; i++)
{
val = data[i];
if(typeof val === 'object')
{
//doing some stuff
}
}
});
</script>
The console:
Object { @file_name="materials", materials=[10], simulations=[10], more...}
undefined
No comments:
Post a Comment