I've seen a lot of sites about this topic, but I can't get any of the examples and instructions to work for me.
I want to loop through some JSON using jQuery. In the JSON example below I'd like to output "model-1" and then output just the "origin". Once that is done then I would do the same thing for the next entry which in this case is "model-2". This could go on hundreds of times until it is finished so I can't specifically call of the entries ("model-1", "model-2", "model-3", etc.) by name.
{
"model-1": {
"origin": "Japan",
"price": "$149",
"availability": "Available"
},
"model-2": {
"origin": "USA",
"price": "$199",
"availability": "Available"
}
}
And here is the code I have so far to do this.
jQuery(function($) {
$.getJSON('/mydata.json', function(data) {
var obj = jQuery.parseJSON(data);
});
});
I would add more extensive code including my loop, but literally nothing I've tried has given me good results. Either I get nothing and it breaks or I get a bunch of 'undefined's. Any help would be greatly appreciated.