Hello. I'm having a problem with a popular select with JSON. When the value has 2 or more words the 'value' of my option is not filled correctly. Example:
{
"Marcas": {
"Acura": {
"Modelos": ["Integra", "Legend", "NSX"]
},
"Alfa Romeo": {
"Modelos": ["145", "147", "155"]
}
}
$.getJSON('models.json', function(data) {
$.each( data, function( key, val ) {
$.each(val, function(make, value){
console.log(make, value)
var option = '<option value='+make+'>'+make+'</option>';
$(option).appendTo("#marcas_list");
});
});
});
Results:
Notethat<optionvalue="Alfa" romeo></option>
is being filled incorrectly.
Anything wrong with the code? Any suggestions?
Hugs!