With "data" being JSON, why does this script not work? I am using "$.parseJSON(data);" to convert the JSON to an array, and the last line of code is how I would typically access the resulting array.
{
"refTopic": [
{
"REFTOPICABV": "Purpose",
"REFTOPICVALUE": "Purpose and Need",
"REFTOPICID": 65
},
{
"REFTOPICABV": "Description",
"REFTOPICVALUE": "Project Description",
"REFTOPICID": 66
}
]
}
if (refTopic == undefined) {
getTopicsSelectBox(function(data) {
console.log(typeof data); //string
var refTopic = $.parseJSON(data);
console.log(typeof refTopic); //object
console.log(refTopic instanceof Array); //false
console.log(refTopic[i].REFTOPICID); //undefined
});
}
refTopic['refTopic'][0]['REFTOPICID']