I have Json object like this
{
" resultArr": [
{
"ID":"1",
"0":"1",
"APPROVAL LEVEL":"1",
"1":"1",
"WorkFlow Type Code":"1",
"2":"1",
"Employee Number":"825489602V",
"3":"825489602V",
"Employee Name":"Wajira Wanigasekara",
"4":"Wajira Wanigasekara"
}
]
}
i am trying to print the key and values of the resultArr.
for example, i want to print ID=1 APPROVAL LEVEL=1.. like that
i can get value of ID,APPROVAL LEVEL.. using this code
$.ajax({
type: "POST",
async:false,
url: "<?php echo url_for('workflow/getApprovalByModuleView') ?>",
data: { viewName: viewName },
dataType: "json",
success: function(data){
alert(data.resultArr[0][3]);
}
});
but i want print the those names also...
that mean i want the print the KEY and VALUE of the data.resultArr array
how can i do that?
Well you use key to select values. The only way I can think of is by looping trough them:
$.each(data.resultArr, function(index, value) {
alert(index + ': ' + value);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With