I am trying to append this JSON array to a select box
{
"10":"Branche",
"2":"Marketing & Comunicatie",
"8":"Test Branche 1",
"9":"Test Branche 2",
"6":"Test Branche 3",
"7":"Test Branche 4",
"1":"Webdevelopment & design"
}
But it doesn't work I encoded it from a PHP array. This is how I am trying to loop through it.
this.addOption = function(name, table, value){
$.ajax({
type: "POST",
data: {action:'add', table:table, value:value},
url: "index.php",
})
.done(function( obj ) {
$("#"+name+"-select").empty()
console.log(name);
$.each(obj, function( key, value ) {
$("#"+name+"-select").append('<option value='+key+'>'+value+'</option>');
});
});
}
Where obj is the JSON array.
It is giving me this error:

obj? Maybe it needs to be parsed again.dataType: 'json'in your$.ajax()options?