I have receive json object form server like below one,
{"locations": [{"locationCode": "Branch 1","locationName": "BR-001"},
{"locationCode": "Branch 2","locationName": "BR-002"},
{"locationCode": "Branch 3","locationName": "BR-003"}
]}
then I need to append locationCode for value and locationName for the text
<option value="locationCode">locationName</option>
I have tried this one but couldn't do it
var location = data.locations;
$.each(location, function (key, value) {
$('#newLocation')
.append($("<option></option>")
.attr("value", key)
.text(value));
});