Reputation: 952
I am making an AJAX call to an API like this,
$.ajax({
url: 'http://dev.markitondemand.com/MODApis/Api/v2/InteractiveChart/jsonp?parameters={"Normalized":false,"NumberOfDays":1095,"DataPeriod":"Day","Elements":[{"Symbol":"AAPL","Type":"price","Params":["ohlc"]}]}',
dataType: 'jsonp',
success: function(data) {
//output = JSON.stringify(data, null, '\t')
$('#container').html(JSON.stringify(data.Elements.Currency, null, '\t'));
}
});
The resultant JSON file is huge and I want to extract value of Elements->Currency.
What am I doing wrong here?
Upvotes: 2
Views: 201
Reputation: 32354
Use the dot notation, no need to stringify the data
success: function(data) {
alert(data.Positions);
}
or use a loop for elements:
success: function(data) {
$.each(data.Elements,function(i,v){
console.log(v.Currency);
});
}
Upvotes: 1
Reputation: 27192
Try this :
success: function(data) {
console.log(data.Elements[0].Currency);
}
Upvotes: 2