In the continuation of my OData routine, getFieldData function along with func1 are being used. While alert1 is functioning as expected, alert2 is not displaying the desired output. How can I fix this issue and make alert2 work flawlessly? My goal is to make this routine reusable for other functions, but I am struggling with passing parameters effectively.
function func1(){
var param1 = 'FullName';
getFieldData(this, param1);
}
function getFieldData(retrieveReq, param1) {
if (retrieveReq.readyState == 4 && retrieveReq.status == 200) {
var retrieved = this.parent.JSON.parse(retrieveReq.responseText).d;
alert('alert1: ' + retrieved.results[0].FullName);
alert('alert2: ' + retrieved.results[0][param1]);
}
}