My object is as below
var masterData = {
"region":[
{"key":"1","value":"AMS"},
{"key":"2","value":"APJ"},
{"key":"3","value":"EMEA"}
]
};
var key = 'region';
var strList = 'masterData.'+key;
$.each($(strList), function(i, row) {
alert(row.key);
});
It's not entering the loop, but if I replace the variable with the actual object, it works. For example:
$.each($(masterData.region), function(i, row) {
alert(row.key);
});
I want to do the same via a variable, like the first one. What am I missing here?