The browser is IE8 and I would just like to resolve the getValueCovid function to retrieve ACCT_NO. The other getValueFromStructure is working.
getValueCovid has the full xml response as response.
I have the below XML and I already have a javascript function that gets the elements from structure. What I want to do is write a seperate javascript function to retrieve ACCT_NO and values from the 'Fields' level. Code below
<Response>
<Cl586>
<Fields>
<Field name="ACCT_NO">
<Value>12345</Value>
</Field>
<Structure id="2002" index="1">
<Field name="ACCT_STATUS">
<Value>TEST</Value>
</Field>
</Structure>
</Fields>
</Cl586>
</Response>
Working javascript for structure getting by index:
getValueFromStructure : function (structure, name) {
if (structure !== null && structure.hasOwnProperty('fields')) {
for (var i=0; i < structure.fields.length; i++) {
if (structure.fields[i].name === name) {
return structure.fields[i].value;
}
}
}
return null;
},
My attempt to get ACCT_NO which I want to fix
getValueCovid : function(response, name) {
if (response !== null && response.hasOwnProperty('fields')) {
for (var i=0; i < response.fields.length; i++) {
if (response.fields[i].name === name) {
return response.fields[i].value;
}
}
}
return null;
},
Then in seperate file I want to retrieve ACCT_NO. Including so you have more idea:
$('#accountNumber').val(ClRestServices.getValueCovid(response, 'ACCT_NO'));