I am storing field value (Sales, ProductName) from json in an array named 'data[]' and 'name[]'. Below is the code which works fine.
function onCompletedCallback(response, eventArgs) {
var chartlist = eval("(" + response.get_responseData() + ")");
var markup = " ";
//Display the raw JSON response
markup += response.get_responseData();
// alert(markup);
var jsonData=jQuery.parseJSON(markup);
// alert(jsonData);
//declaring arrays
var name = [];
var data = [];
$.each(jsonData.d.results, function (index, value) {
data.push(value.Sales);
name.push(value.ProductName);
});
}
Now what I want to pass field values from dropdown(ddlxField) in my UI, which holds all the fieldname of the list and pass it to json object while pushing data in 'name' array. For now am choosing 'ProductName' form dropdown, i.e, xName=ProductName
var xName = document.getElementById("ddlxField").value;
$.each(jsonData.d.results, function (index, value) {
data.push(value.Sales);
name.push(value.xName); // xname value= ProductName
});
But after execution, xName is coming out to be undefined. can anyone suggest what else can be done or where am going wrong?