$.ajax({
type: "POST",
url: "<%=Page.ResolveClientUrl("~/api/ws.asmx/GetHighPriorityInquiries") %>",
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (data) {
/*console.log(data.d);*/
var json = $.parseJSON(data.d);
if (json != '') {
var columnsIn = json[0];
for (var key in columnsIn) {
if (key.length != 0) {
for (let ctr = 0; ctr < arr.length; ++ctr) {
if (key == arr[ctr]) {
validColumnsArray.push(arr[ctr]);
/*console.log(validColumnsArray);*/
}
}
}
//else {
// console.log('No Columns');
//}
}
arr = [];
debugger;
$.each(json, function (i) {
//TODO: populate the columns with data here
for (let j = 0; j < validColumnsArray.length; ++j) {
var curentCol;
currentCol = validColumnsArray[j];
console.log(currentCol);
var test = JSON.stringify(json[i]);
/*var arrayIndex = test.indexOf(curentCol); */
console.log(test);
arr.push(json[i].validColumnsArray[j]); /* not storing the json data on this part */
console.log(arr);
}
});
}
},
error: function (err) {
alert(err.responseText);
}
});
Hi Team! I am trying to access each element of a json object. The problem is, since the columns are not static(meaning it is user defined), I have to store the selected columns in an array and then access the value of the each column based on the array. you can check the screenshot variable named "curentCol". The question is, Is it possible to append the curentCol variable to json[0] to get the specific column value (i.e. json[0].name)? I tried it but I am getting undefined when I store it to a new array. Thanks for the help.