I have the following json array returning from an ajax call:
{"err":"err_type","fields":["field1","field2"]}
when tryin to print it out with this function:
$.each(data.fields, function (i, field) {
console.log(field);
$.each(field, function (j, f) {
$('[name="'+f+'"]').addClass('form_err');
console.log(f);
});
});
i get this:
data1
TypeError: invalid 'in' operand a
...turn function(b){return db(a,b).length>0}}),contains:fb(function(a){return funct...
and so i can't figure out how to use this array! Anyone have any idea?
You are iterating a string, you don't need two .each() functions
$.each(data.fields, function (i, field) {
$('[name="'+field+'"]').addClass('form_err');
console.log(field);
});
Remember to add dataType: 'json';
so that it can be looped as an array and not a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With