I have seen many examples and I have used this myself in many of my programs but for some reason this doesn't want to work today.
I have JSON data that I can show in console.log
but it is unusable in my select
. I get this error in my console:
Cannot use 'in' operator to search for '76' in {"hello1":"hello1","hello2":"hello2"}
This is my code:
$.get("JSON.php?value=two", function(response) {
console.log(response);
// this is what my JSON returns
// {"hello1":"hello1","hello2":"hello2"}
if (response != '') {
$('#dropdown').find('option').remove();
$.each(response,function(key, value){
$('#dropdown').append('<option value=' + key + '>' + value + '</option>');
});
}
)};