Dealing with a rather intricate JSON structure, I'm encountering difficulty iterating through it using the $.each() function. It seems to be related to the unusual 2-dimensional array passed in the value section of the standard array (hopefully that makes sense). Since I am new to Ajax and JSON, I just need some advice on the most effective way to manage JSON returned via an AJAX Call. Thank you!
$.ajax({
type: 'POST',
url: 'model.php',
data: formData,
dataType: 'json',
encode : true
}).done(function(data){
var i = 0;
for(var k in data){
window.alert(k);
} //this works
$.each(data, function(key, value){ //however this does not display anything
window.alert("should be outputted");
window.alert("key" + key + "value" + value[i]['email']);
i++;
});
});
Here is the JSON snippet I'm working with:
{"bodge.com":[{"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="157872777760647655777a7172703b767a78">[email protected]</a>",... etc.