UDPATE: SO WHATS THE BEST WAY TO ILLITERATE THROUGH A MULTI DIMENSIONAL ARRAY. SO CHECKING FOR OBJECTS INSIDE COMPLEX ARRAYS AND GRABBING THEIR VALUES.
{ "error":{
"data": {
"id":"3",
"name":"404",
"content" : "value"
},
"response":"Invalid path.",
"code": 1
}
}
if(json.error.data !== undefined) {
alert('value: ' + json.error.data);
}
I'm having an issue here; I can't seem to correctly resolved. When I try to check an array for a value it returns the error "Uncaught TypeError: Cannot read property 'data' of undefined" if the array data doesn't exist or content isn't present. I know there is a way to use indexOf() to test if the value is present, but this doesn't help me. I need to test for that value and then capture it. Remember, this is a multidimensional array so just using indexOf won't necessarily locate the complexity of the array and how to locate it.
Ok, so put simply. I need to say, does the array data and the parameter content exist in the error array shown above. If it does, then capture it's value and do something.
I also read about jQuery.inArray(); I don't know how to utilize this for complex multidimensional arrays.
Is the only successful way to do this using a loop for( x in z) {}