I have a JSON response like this:
{"error":true,"variable":{"v_f1_email":["error-mail","mail"]}}
I am trying to access 'error-mail' and 'mail' like this:
var JSD = JSON.parse(data);
if (JSD.error == true) {
$(JSD.variable).each(function(index, el) {
var error = el[0];
var type = el[0];
console.log(error + type);
})
Unfortunately the vars error and type are returning undefined. Where am I wrong? Thanks
v_f1_email...?var errormsg = JSD.variable.v_f1_email; console.log(errormsg[0],errormsg[1])errorandtypeto the same element?eachmethod. jQuery has two: one is for jQuery objects, the other is for arrays/objects.