Possible Duplicate:
Dynamic object property name
With an ajax call I receive an object: E
This objects holds a number of child elements: width
, height
, etc.
console.log (E.width)
gives me all elements of E.width
When I assign a var: tempElement = 'width'
Why does console.log(e.tempElement) returns 'undefined' and how can i access a child element of the object by a variable
$(function () {
$('#widthSelect').on('change', function () {
var updateArray = new Array();
updateArray[0] = 'height';
updateArray[1] = 'rim';
updateArray[2] = 'load';
updateArray[3] = 'speed';
updateArray[4] = 'brand';
updateArray[5] = 'season';
getValues(updateArray);
});
function getValues(updateArray) {
var data = updateArray.join('=&') + '=';
$.ajax({
type: 'POST',
dataType: 'json',
url: '******',
data: data,
success: function (e) {
element = updateArray[0];
console.log(e.element);
}
});
}
});